如何使用 cURL 向网站发出请求,并让该网站相信我是一个搜索引擎。
您可以将您的用户代理设置为Googlebot的(更多关于Google KB上使用的确切用户代理的信息,请参考:Google's KB):
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
但这种方法并不总是有效的!一些网站可能会选择对声称自己是Googlebot的用户进行反向DNS检查。
-A "'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)')"
来模拟谷歌爬虫的用户代理。请注意保持内容的原意,并使其更加易于理解,不要添加任何额外的注释或信息。 - Gabriel Petrovay
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
设置用户代理。 - naththedeveloper