【发布时间】:2019-04-27 18:10:01
【问题描述】:
我正在尝试搜索 Transfermarkt,一个足球网站。我正在尝试进行网络抓取,但每次尝试我都会在第 7 次请求时被阻止。
我尝试更改标头和代理,但总是得到相同的结果。
这些是我做的一些“实验”。这些代理分开工作。
user_agent_list = [here are a lot of user agents]
headers = {'User-Agent':random.choice(user_agent_list)}
url='https://www.transfermarkt.es/jadon-sancho/profil/spieler/14'
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://121.121.117.227:3128'})
print(r)
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://121.121.117.227:3128'})
print(r)
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://121.121.117.227:3128'})
print(r)
#Changing proxy
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://177.131.22.186:80'})
print(r)
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://177.131.22.186:80'})
print(r)
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://177.131.22.186:80'})
print(r)
#Here I get blocked
r=requests.get(url,headers='User-Agent':random.choice(user_agent_list),proxies={'http': 'http://177.131.22.186:80'})
print(r)
#And continue trying with another examples
我必须说明代理已经过验证,因此请单独工作。我从 prints 中得到的是直到我被阻止,我得到 .我该如何解决?我应该从 get 中更改另一个参数吗?
【问题讨论】:
标签: python web-scraping python-requests