2019-05-13--重学Python28--异步加载get请求数据失败。


'''
1,网址:http://www.cwl.gov.cn/kjxx/ssq/kjgg/ 要爬取的网址。
2,异步调取的数据。"http://www.cwl.gov.cn/cwl_admin/kjxx/findDrawNotice?name=ssq&issueCount=30"
但是当我用request访问这个网址的时候,却没有响应的数据返回,这就很尴尬了!
如何?XHR中的response返回的数据
这个人遇到的问题,跟我遇到的一样!:https://bbs.csdn.net/topics/392498560


'''

import time
import requests
from bs4 import BeautifulSoup
import json


url = "http://www.cwl.gov.cn/kjxx/ssq/kjgg/"
url2 = "http://www.cwl.gov.cn/cwl_admin/kjxx/findDrawNotice?name=ssq&issueCount=30"

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0",
            "X-Requested-With": "XMLHttpRequest",
            "Refer": "http://www.cwl.gov.cn/kjxx/ssq/kjgg/",
            "Cookie" : "UniqueID=QihgWkw9KKCJczzT1557672740945; Sites=_21; _ga=GA1.3.1905837340.1557672793; _gid=GA1.3.630592267.1557672793; Hm_lvt_bfc6c23974fbad0bbfed25f88a973fb0=1557673683; Hm_lpvt_bfc6c23974fbad0bbfed25f88a973fb0=1557673683; 21_vq=2"
            }
data = {
    "name": 'ssq',
    "issueCount": '30'
}
roomSession  = requests.Session()
t1 = roomSession.get(url2,headers = headers)
# soup = BeautifulSoup(t1.content,"lxml")
# book = json.loads(t1.text,encoding="utf-8")

print(t1.headers)
print(t1.elapsed)

你可能感兴趣的:(2019-05-13--重学Python28--异步加载get请求数据失败。)