首页 > 解决方案 > 使用带有地理定位的请求问题使用 python 进行 Webscraping

问题描述

我目前正在通过请求和使用代理来抓取 amazon.com 网站。

我正在将请求模块与python3一起使用。

我面临的问题是亚马逊根据代理的地理位置向我返回结果,而不是美国 amazon.com 的结果。

我如何确保仅从美国获得针对美国的 amazon.com 的结果?

这是我的代码:

import requests
url = 'https://www.amazon.com/s?k=a%20circuit'
proxy_dict = # Proxy details in the dictionary form
response = requests.get(url, proxies=proxy_dict, timeout=(3, 3))
htmlText = response.text
# I am than saving the details in a text file.

该代码工作正常,但它确实返回代理位置的结果。

我如何确保结果仅适用于美国?Shell 我可能会在 url 上添加一些东西或在标题上添加一些东西?

标签: pythonweb-scrapingrequestgeolocation

解决方案


推荐阅读