Please let me know what's wrong with this. I don't see it.
The code is as follows: Is there any problem with the writing method?
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
Yourreq
没有符合url的格式, 看到报错, req
的结果是http://<Request[403]>
刚才去看了requests
的模块定义, 觉得requests.request
has already initiated a visit
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 # 直接输出
淡淡烟草味2017-05-18 10:51:47
There seems to be something wrong with the way user_agent in the header is written. It should be written the same way as the browser