爬蟲爬拉鈎網出現 您操作太頻繁,請稍后再訪問 解決


爬蟲爬拉鈎網出現 您操作太頻繁,請稍后再訪問 解決

一、總結

一句話總結:

爬拉勾網數據的時候,ajax的post請求是需要cookie的,還需要在header里面需要添加Accept、Referer、User-Agent

 

 

二、爬蟲爬拉鈎網出現 您操作太頻繁,請稍后再訪問 解決

轉自或參考:{"status":false,"msg":"您操作太頻繁,請稍后再訪問","clientIp":"113.94.81.141"}
https://www.freesion.com/article/140098505/

在爬取拉勾網的時候報錯{"STATUS":FALSE,"MSG":"您操作太頻繁,請稍后再訪問","CLIENTIP":"113.94.81.141"}

 

需要獲取搜索結果那一頁的cookie 以及header里面需要添加Accept、Referer、User-Agent

 

 

 

 

 

 1 import requests 
 2  
 3 url = 'https://www.lagou.com/jobs/positionAjax.json?city=%E5%B9%BF%E5%B7%9E&needAddtionalResult=false'
 4  
 5 payload={
 6     'first': 'true',
 7     'pn': '1',
 8     'kd': '自然語言處理'   
 9 }
10  
11 header = {
12     'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36',
13     'Referer': 'https://www.lagou.com/jobs/list_%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86?px=default&city=%E5%B9%BF%E5%B7%9E',
14     'Accept': 'application/json, text/javascript, */*; q=0.01'
15 }
16  
17 urls ='https://www.lagou.com/jobs/list_%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86?city=%E5%B9%BF%E5%B7%9E&cl=false&fromSearch=true&labelWords=&suginput='
18 s = requests.Session()
19 # 獲取搜索頁的cookies
20 s.get(urls, headers=headers, timeout=3)
21 # 為此次獲取的cookies
22 cookie = s.cookies
23 # 獲取此次文本
24 response = s.post(url, data=payload, headers=header, cookies=cookie, timeout=5).text
25 print(response)

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM