Scraping data with php -


i beginner in scraping , using php simple_html_dom scrape data website. current code not displaying results. maybe don't target proper html tag. second thing need if there no results searched query code displays message: "results not found" or that. appreciated.

here sample queries:

3lnhl2gc9br764854 1j4ff28sxxl550156

  <?php     require "simple_html_dom.php";  $trazi=$_post['trazi'];    $url="http://lookupvin.com/check/";    $ch = curl_init();  curl_setopt($ch, curlopt_url,$url);  curl_setopt($ch, curlopt_post, 1);  curl_setopt($ch, curlopt_postfields,              "vin=$trazi");  curl_setopt($ch, curlopt_returntransfer, true);  $server_output = curl_exec ($ch);  curl_close($ch);      $html = str_get_html($server_output);      foreach($html->find('p.nmar') $element)    echo $element->innertext();   ?>  index.php <form action="vin.php" method="post">     <input type="text" name="trazi">     <input type="submit"> </form> 

include "simple_html_dom.php";     $trazi="1j4ff28sxxl550157";     $url="http://lookupvin.com/check/";     $ch = curl_init();     curl_setopt($ch, curlopt_url,$url);     curl_setopt($ch, curlopt_post, 1);     curl_setopt($ch, curlopt_postfields, "vin=$trazi");     curl_setopt($ch, curlopt_returntransfer, true);     $server_output = curl_exec ($ch);     curl_close($ch);  $html = new simple_html_dom(); $html->load($server_output); $items = $html->find('.nmar');  if(count($items)!=0) {     foreach($items $post) {         echo $post->children(0);         echo "<br>";     } } else {     echo "wrong input"; } 

found better class online better html parsing. http://code.tutsplus.com/tutorials/html-parsing-and-screen-scraping-with-the-simple-html-dom-library--net-11856 can download here.

the result received. enter image description here


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -