Hi,
I have suddenly starting receiving HTTP error code 403 and error code 1020 when scraping a web-site using curl, that I have been scraping for several years. I can load the website fine in my web-browser from the same device / IP as the web server.
Any suggestions would be greatly appreciated. I have included the code below referencing the relevant web-site:
function get_data($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_HEADER, true);
$data = curl_exec($ch);
if (!curl_errno($ch))
{
switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE))
{
case 200: # OK
break;
default:
echo 'Unexpected HTTP code: ', $http_code, "\n";
}
}
curl_close($ch);
return $data;
}
$url = "https://www.oddschecker.com/";
$returned_content = get_data($url);
echo "<Br>".$returned_content;