#請大神指教這是錯在哪裡了,沒看出來。
程式碼如下:寫法又問題嗎?
import requests
base_url = 'https://xueqiu.com/hq#exchang...';
headers = {'user_agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML , like Gecko) Chrome/53.0.2785.89 Safari/537.36'}
req = requests.request(method='get',url=base_url,headers=headers)
rsp = requests.get(req)
巴扎黑2017-05-18 10:51:47
你的req
没有符合url的格式, 看到报错, req
的结果是http://<Request[403]>
刚才去看了requests
的模块定义, 觉得requests.request
就已經是發起訪問了
import requests
base_url = 'https://xueqiu.com/hq#exchang...';
headers = {'user_agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.89 Safari/537.36'}
req = requests.request(method='get',url=base_url,headers=headers)
print req.text # 直接输出