I am trying to scrape stack overflow's php newest questions on the basis of 45 questions per page.I am using Simple_html_dom for the parsing. I am almost done but i couldn't scrape the values for the no of answers given to a question as they are using two seperate div tags. Below is the code link to check for and i am also attaching a screenshot link of what the executed code gives.
include_once('simple_html_dom.php');
function httpGet($url)
{
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
$count=45;
$url ='http://stackoverflow.com/questions/tagged/php?page=1&sort=newest&pagesize='.$count;
$parse = httpGet($url);
$html = str_get_html($parse);
for($i=0;$i<=$count;$i++){
$qu=$html->find('a[class=question-hyperlink]', $i)->href;
$que='https://stackoverflow.com'.$qu;
$question=$html->find('a[class=question-hyperlink]', $i)->plaintext;
$link='<a href="'.$que.'">'.$question.'</a>';
$time=$html->find('span[class=relativetime]',$i)->plaintext;
$views=$html->find('.views',$i)->plaintext;
$vote=$html->find('span[class=vote-count-post]',$i)->plaintext;
$stat1=$html->find('div[class=status answered]',$i)->plaintext;
echo'<h3>'.$link.'</h3>  Asked: '.$time.'Vote:'.$vote.'View:'.$views.'Answers: '.'<br><br>';
}
In the image you can see Answers: "Here is where i wanna get the number of answers a question got" Looking for solution with simple_html_dom, although regex answers will also work
Thanks