Excerpt Extract PHP from Page

Does anyone know how to generate an excerpt from any page of an article (so it can be a source from many types of sites)? Something like facebook does when you paste the url into the message. Thanks.

+4
source share
2 answers

What you want to do is called a web scraper . The main method for this would be to grab the page (you can clear the URL using file_get_contents ) and then somehow parse it for the content you want (i.e. pull the content from the <body> ).

To parse the returned HTML, you must use the DOM parser. PHP has its own DOM classes that you can use.

+5
source

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


All Articles