I am looking to scrape some content of webpages.
I have the following code but it does 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 for 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
is not working, but when I use $url2
it works like charm.
What can I do to fix this?