Copy text from a webpage

12,849

Solution 1

<?php
$content = file_get_contents('http://speedywap.com');
echo $content;
?>

you can use strip_tags to strip tags from it then you are just left with text.

Solution 2

For a very naïve start, you can use this:

<?php

echo strip_tags(file_get_contents('http://speedywap.com'));

?>

Solution 3

function curl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    return curl_exec($ch);
    curl_close ($ch);
}

$html = curl('http://speedywap.com');

cURL is many times faster then fgc. You can use strip_tags but that doesnt guarantee anything, only way is to manually parse the page, using str_replace, preg_replace etc.

This is what you get using strip_tags : http://pokit.etf.ba/get/47a07bd62ea42dd3d447f060c01ccfb5.png

Solution 4

develop your code on this ->http://www.barattalo.it/2010/03/01/php-curl-bot-to-update-facebook-status/

Share:
12,849
Speedy Wap
Author by

Speedy Wap

Updated on June 04, 2022

Comments

  • Speedy Wap
    Speedy Wap almost 2 years

    Let's say we have a website speedywap.com

    When I open the website in my browser and then I copy the page to the clipboard and when I paste it in my notepad (windows) only text remains. All the code is removed except for the text that was in links etc (i.e displayed on the screen).

    I want to do something similar with php because I am trying to create a keyword density analyser. So I want something that is able to just keep the text from a webpage that is displayed on the screen.

    My server is running apache, php, centos and mysql