Possible Duplicate:
CodeIgniter: A Class/Library to help get meta tags from a web page?
I need to be able to get the TITLE and DESCIPTION m开发者_运维技巧etadata out of a page.
I've been trying to do this but I've been getting more errors than actual results. (I have an array of about 10 URLS, usually only about 2 of them give me the descrption. I have yet to get the title).
So how do I, in PHP, get the Desc and Title from a remote page, and if there is none or if there's an error, ignore it?
-Dylan
Use something like cURL (Checking things like the result isn't false and that the HTTP status is 200) to get the page and then Simple HTML DOM to parse it and extract the elements you want. (Remembering that the elements might not exist)
精彩评论