스크립트망의 어떤 단어의 검색 데이터를 찾아서 비동기적으로 불러오기

4817 단어
 1 # URL —— 
 2 
 3 #  URL, cookie, url
 4 start_url = 'https://www.lagou.com/jobs/list_%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/p-city_0?&cl=false&fromSearch=true&labelWords=&suginput='
 5 
 6 url = 'https://www.lagou.com/jobs/positionAjax.json?needAddtionalResult=false'
 7 
 8 headers = {'User-Agent': "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0",
 9           'Connection': 'keep-alive',  #  
10            'Referer': 'https://www.lagou.com/jobs/list_%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90?labelWords=sug&fromSearch=true&suginput=%E6%95%B0%E6%8D%AE'
11           }
12 data = {'first': 'true',
13         'pn': '1',
14         'kd': ' '}
15 # response = requests.post(url, headers = headers, data = data)
16 
17 #  session 
18 session = requests.session()
19 
20 #  session ,  cookie 
21 session.get(start_url, headers = headers)
22 
23 #  cookies session POST , 
24 response = session.post(url, headers = headers, data = data, cookies = session.cookies)
25 print(response.status_code)
26 print(response.text)

좋은 웹페이지 즐겨찾기