kamong kamong kamong kamong - 9 days ago 6
Javascript Question

How to get text on webpage by url (need some idea or advice)?

How to get text on webpage by url (need some idea or advice)?

Normally i use this code for get file data using url

<?PHP
$text = file_get_contents('https://www.example.com/sometextfile.txt');
echo $text;
?>


Now i want to get all text on webpage using url.

can i do that by php or javascript ?

Answer

If you are trying to access the text from external URL then you can simply use file_get_contents function with strip_tags:

<?PHP
$text = file_get_contents('https://www.example.com/sometextfile.txt');
echo strip_tags($text); // If you only need text not html structure
?>

Another PHP way of doing this is CURL. You can enable php_curl and use the curl method to do this(http://php.net/manual/en/curl.examples.php).