php - how to extract specific span content from webpage -
i looking scrape content of webpages.
i have following code not work on every page.
$url1 = 'http://www.just-eat.co.uk/restaurants-tomyumgoong/menu'; $url2 = 'http://www.just-eat.co.uk/'; $curl = curl_init($url1); curl_setopt($curl, curlopt_returntransfer, true); $page = curl_exec($curl); if (curl_errno($curl)) // check execution errors { echo 'scraper error: ' . curl_error($curl); exit; } echo $page; curl_close($curl); $regex = '/<div class="responsive-header-logo">(.*?)<\/div>/s'; if (preg_match($regex, $page, $list)) echo $list[0]; else print "not found";
$url1
not working, when use $url2
works charm.
what can fix this?
try simplifying regex just:
$regex = '/responsive-header-logo/';
Comments
Post a Comment