tags:

views:

38

answers:

2

Hi, anyone have any idea how to generate excerpt from any given article page (so could source from many type of sites)? Something like what facebook does when you paste a url into the post. Thank you.

+3  A: 

What you're looking to do is called web scraping. The basic method for doing so would be to capture the page (you can scrape a URL using file_get_contents), and then somehow parse it for the content that you want (ie. pull out content from the <body> tag).

In order to parse the returned HTML, you should use a DOM parser. PHP has its own DOM classes which you can use.

Daniel Vandersluis
+1  A: 

Here is a video tutorial about how to do that:

http://net.tutsplus.com/tutorials/php/how-to-create-blog-excerpts-with-php/

Hassan Al-Jeshi