Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy text from a webpage

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

like image 646
Speedy Wap Avatar asked Sep 21 '25 09:09

Speedy Wap


1 Answers

<?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.

like image 90
Vishvadeep Avatar answered Sep 22 '25 23:09

Vishvadeep