get请求一个url=‘http://www.chanpin100.com/pm/list?page=4&end_id=107371’
尝试1:我先直接请求的,结果是一直显示在请求,无法停止,等了估计几分钟后才最后直接报错。
尝试2:然后我又加了个header,结果是:报超时
问题1: 我错在哪,为什么?
问题2: 要如何才能成功的返回数据内容,最好是能快速的?
主要是对header有做一些检测。加上对应的字段就可以了
In [7]: headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36', 'Referer': 'http://www.chanpin100.com/pm/', 'X-Requested-With': 'XMLHttpRequest'}
In [8]: res = requests.get('http://www.chanpin100.com/pm/list?page=4&end_id=107371', headers=headers)
In [9]: res
Out[9]: <Response [200]>
给post加上参数: 超时时间 timeout=(1,3))