import requests from copyheaders import headers_raw_to_dict url = 'https://eregpublicsecure.ksrzis.cz/Registr/RZPRO/Osoba' post_url = url + "/GetOsobaList" # headers信息 X-Requested-With 异步请求的时候需要 headers_raw = b"""X-Requested-With: XMLHttpRequest""" header = headers_raw_to_dict(headers_raw) # 获取cookie sess = requests.Session() response = sess.get(url) cookies_geted = response.cookies page = 1 page_size = 1000 search_dict = { 14: "distributor obecných zdravotnických prostředků", 15: "distributor aktivních implantabilních zdravotnických prostředků", 16: "distributor diagnostických zdravotnických prostředků in vitro", } data = { "sort": "", "page": page, "pageSize": page_size, "group": "", "filter": "CinnostOsoby~undefined~'" + str(list(search_dict.keys())[0]) + "'~and~Nazev~undefined~''~and~Adresa~undefined~''~and~ICO~undefined~''~and~RegCislo~undefined~''~and~ZdravotnickyProstredek~undefined~''", } response = sess.post(post_url, data=data, headers=header, cookies=cookies_geted) print(response.status_code)
标签:Requested,cookies,ch,undefined,异步,url,爬虫,headers,page From: https://www.cnblogs.com/avivi/p/17385484.html