Copy text from a web page

Let's say we have speedywap.com

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

I want to do something similar with php because I'm trying to create a keyword density analyzer. So I want something that can just save the text from the webpage displayed on the screen.

My server runs apache, php, centos and mysql

+3
source share
7 answers
<?php
$content = file_get_contents('http://speedywap.com');
echo $content;
?>

strip_tags, , .

+5

:

<?php

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

?>
+2
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 , fgc. strip_tags, , - , str_replace, preg_replace ..

, strip_tags: http://pokit.etf.ba/get/47a07bd62ea42dd3d447f060c01ccfb5.png

+1

→ http://www.barattalo.it/2010/03/01/php-curl-bot-to-update-facebook-status/

+1

file_get_contents curl, .

<?php
$content = file_get_contents('http://speedywap.com');
echo $content; // or analyze, or whatever
0

file_get_contents('http://www.speedywap.com/');, , / , , .

0
source
0
source

Source: https://habr.com/ru/post/1782360/


All Articles