views:

28

answers:

2

Hi,

I'm looking to achieve the effect facebook has when you put a link into a message - they scrape the title and some images from it. I noticed they also do it extremely quickly. (they must cache some of the re-sent items?)

Does anyone have any ideas on how to approach this with PHP? Can I somehow quickly grab the <title> block of the page without cURLing the entire thing?

Thanks!

+1  A: 

You would probably have to grab the entire page and use a HTML DOM parser to rip out the title tag.

Like you said, if you want fast speeds consider caching the results.

http://simplehtmldom.sourceforge.net/

ILMV
thanks, i'm currently using simplehtmldom.. its just too slow!plus PHP runs out of memory doing bigger sites, and I feel that there must be a better solution out there...
daniel
I don't know much about cURL, but does it download everything? You could restrict it to just the HTML.
ILMV
@daniel: SimpleHtmlDom is great, but as you mentioned it's slow. Try using phps DOM class -> http://php.net/manual/en/book.dom.php
AntonioCS
A: 

Check out the developer pages to learn how Facebook knows about the content

Gordon