php - Need a regex solution to scrap -


i trying scrap stack overflow's php newest questions on basis of 45 questions per page.i using simple_html_dom parsing. done couldn't scrape values no of answers given question using 2 seperate div tags. below code link check , attaching screenshot link of 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>&nbsp&nbspasked:&nbsp'.$time.'vote:'.$vote.'view:'.$views.'answers: '.'<br><br>'; } 

scraped image

in image can see answers: "here wanna number of answers question got" looking solution simple_html_dom, although regex answers work

thanks


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -