【发布时间】:2021-01-16 19:28:48
【问题描述】:
我想从亚马逊搜索结果和产品详细信息中获取数据。我找到了一些通过 api 获取数据的来源。但我正在寻找没有 api 的获取产品信息。例如:https://www.amazon.com/Apple-MWP22AM-A-AirPods-Pro/dp/B07ZPC9QD4 这是亚马逊产品链接。我想获取此产品数据。我也尝试通过 cUrl/file 获取内容但失败了。请问有人可以帮忙吗?
这是我尝试的代码示例,但它需要验证码
$curl = curl_init('https://www.amazon.com/gp/product/B00M0QVG3W');
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 10.10; labnol;) ctrlq.org");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($curl);
curl_close($curl);
echo $html;
【问题讨论】:
-
到目前为止你完成了吗?提供您的代码
-
I also try by cUrl/file get contents but failed。你得到什么错误? -
是 $curl = curl_init('amazon.com/gp/product/B00M0QVG3W'); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 10.10; labnol;) ctrlq.org"); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $html = curl_exec($curl); curl_close($curl);回声 $html;这是我的代码。在输出其所需的机器人检查验证码
标签: php amazon-web-services api curl file-get-contents