为什么我用python爬取拉勾网的数据,设置了User-Agent和Referer参数,却还是被反爬虫了

代码如下,是跟着视频教程写的一样的:
from urllib import request
from urllib import parse
url = ‘https://www.lagou.com/jobs/positionAjax.json?city=成都&needAddtionalResult=false’

headers = {
‘Referer’: ‘https://www.lagou.com/jobs/list_pythonc?ity=成都&cl=false&fromSearch=true&labelWords=&suginput=’,
‘User-Agent’: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36’
}

data = {
‘first’:‘true’,
‘pn’:1,
‘kd’:‘python’
}

req = request.Request(url, headers=headers, data=parse.urlencode(data).encode(‘utf-8’), method=‘POST’)
resp = request.urlopen(req)
print(resp.read().decode(‘utf-8’))

运行的时候提示我:{“status”:false,“msg”:“您操作太频繁,请稍后再访问”,“clientIp”:“180.85.42.80”,“state”:2402}

显然,我被反爬虫了,请问有大佬知道为什么嘛

你可能感兴趣的:(为什么我用python爬取拉勾网的数据,设置了User-Agent和Referer参数,却还是被反爬虫了)