Hello, I want to get a description of a remote using PHP and CURL. I have used get_meta_tags, but if the site dosen't have a description meta tag it returns nothing. So I want a function that can get a description of a page, from the content posted on it, like what Google does. Thanks, CLM
There's nothing natively in php for this. You'll need to create a function to strip out the html tags (strip_tags) from the page and attempt to read the first bit of useful text. I'd imagine it would be fairly tricky to always get something useful given the first text you get back might be navigation items or site news etc.
I know theres nothing in php that can do this, the only thing close too it is get_meta_tags. If it was as easy as adding strip_tags then I would of already done that. I know its a tricky function to create thats why I posted it on DP.
Google generates snippets based on the search terms provided by the user. Since you wouldn't have such keywords to work from, I'd start by searching the <body> for <p>aragraphs that contain keywords found in the <title> tag and/or the <h1>.
You will need to look into regular expressions (regex) to manage this task. You'll need to search between the <title> tags and the meta description