我尝试使用Curl获得一个pastebin texte文件,但是它不再起作用了。 由于pastebin更改了阻止请求,我该怎么办? (我不想获得一个pastebin支付帐户)
$url = "https://pastebin.com/raw/XXXXXXXX";
file_get_contents_curl($url);
function file_get_contents_curl($url) {
$ch = curl_init();
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
// curl_setopt($ch, CURLOPT_USERAGENT,$agents[array_rand($agents)]);
curl_setopt($ch, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)');
curl_setopt($ch, CURLOPT_TIMEOUT,10);
curl_setopt($ch, CURLOPT_URL, urldecode($url));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}