using php, i'm trying prices things listed on webpage. can please me write correctly? i'm pretty sure i'm writing foreach line wrong because of having $listing? i'm not sure if way long parts written correct, put names , prices $name , $price variables?
<?php $all = file_get_contents('http://shop.hobbylobby.com/search/?keyword=cricut%20cartridge&match=and&f_sort=2&f_all=y'); echo $all; $name = array(); $price = array(); foreach($all $listing) { $name[] = $listing.getelementsbyclassname("listingwrpr").getelementsbytagname("h3").innerhtml; $price[] = $listing.getelementsbyclassname("listingwrpr").getelementsbyclassname("item price").innerhtml; } print_r($name); print_r($price); ?>
you have use of following alternatives.
these php
scripts count table rows can work jquery
functions.
i giving example of simple html dom parser.
include("../simplehtml/simple_html_dom.php"); $html = file_get_html("your url"); foreach ($html->find('.logo') $e) { $obj = str_get_html($e); foreach ($obj->find('img') $ea) { $logoimage = $e->innertext; } }
hope helps.
Comments
Post a Comment