我正在尝试使用这段代码来获取一个网站的产品图片:
<?php
$url="http://www.akasa.com.tw/update.php?tpl=product/cpu.gallery.tpl&type=Fanless Chassis&type_sub=Fanless Mini ITX&model=A-ITX19-A1B";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_ENCODING, "");
$pagebody=curl_exec($ch);
curl_close ($ch);
$html=str_get_html($pagebody);
print_r($html);PHPStorm让我读取变量,$pagebody得到了这个值:
<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. If you think this is an error, please contact the webmaster. <br><br>Your support ID is: 4977197659118049932</body></html>http://www.akasa.com.tw/update.php?tpl=product/cpu.gallery.tpl&type=Fanless Chassis&type_sub=Fanless Mini ITX&model=A-ITX19-A1B
当我使用浏览器时,我完美地看到了页面,pagesource也提供了我所需要的所有有用的信息,但我想自动从其中抓取一些图像。你知道如何找出我需要用cURL发送什么信息,这样网站就不会把我当成机器人(我猜这就是问题所在),或者如何找到解决这些问题的方法?
https://stackoverflow.com/questions/47612138
复制相似问题