我试图用python-3.7刮擦亚马逊。我收到此消息。
“对不起,我们只需要确保您不是机器人即可。为了获得最佳效果,请确保您的浏览器接受cookie。”
如何使python接受cookie?找到解决方案后,是否必须放弃当前使用的IP?
from requests_html import HTML
from requests_html import HTMLSession
import sys
import warnings
session = HTMLSession()
if not sys.warnoptions:
warnings.simplefilter("ignore")
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36'
}
amazon_url="https://www.amazon.com/dp/B00002N6SD"
response = session.get(amazon_url, headers=headers, verify=False) #get the response
print (response.content)
title = response.html.find('#productTitle')
print (title)
exit()
我期待内容和元素。我第一次收到内容,但随后收到消息和验证码。如果我等待一段时间,我会再次得到满足。