Jump to content

Need help extracting strings from webpages using cURL. Where is my code wrong?


Lexicon

Recommended Posts

I'm trying to work on my php skills by creating an online content "finder". I'm using cURL to grab webpage HTML and store it in a variable.

 

I then want my program to find the article title, keywords and the content. I'm using articles from Ezine.

 

here is an example webpage.

 

http://ezinearticles.com/?8-Ways-to-Reduce-Stock-Investment-Risks&id=954266

 

I don't have any problems grabbing the webpage html. But when I try to grab the title, keywords, and content using this code.

 

$title = getbetween($html, "<title>", "</title>");
$keywords = getbetween($html, "<meta name=\"keywords\" content=\"", "\">");
$content  = getbetween($html, "<div id=\"body\">", "</div>");
$content  = "<P>" . getbetween($content . "<E>", "<P>", "<E>");

echo "Title: " . $title . "<P>";
echo "Keywords: " . $keywords . "<P>";
echo "Content: " . $content . "<P>";

 

Only the title comes out of the page, the rest of the values are blank... I'm not sure why the getbetween is only working to extract the title from the html. Does anyone have any ideas why??

 

I tried testing to see if it was grabbing the propper webpage and when I used 'echo $html;' the webpage came out fine on my page..

 

I am totally lost on this, I just want to practice using cURL and my webrequest coding.

 

Thanks for any help, I appreciate it.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.