python - httplib get 请求报错 httplib.BadStatusLine: ''
巴扎黑
巴扎黑 2017-04-17 15:20:51
0
1
583

我想通过这条 api 获取手机号的区域信息
http://virtual.paipai.com/extinfo/GetMobileProductInfo?mobile=13333333333&amount=10000
正常应该是这样的
({mobile:'13333333333',province:'河北',isp:'中国电信',stock:'1',amount:'10000',maxprice:'0',minprice:'0',cityname:'秦皇岛'});

但是现在报错httplib.BadStatusLine: ''
在浏览器打开是没有问题的,下面是执行的代码,谢谢大家了。

import httplib
import urllib
headers = {"Content-type":"text/html; charset=gb2312", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8","Accept-Encoding":"gzip,deflate,sdch","Accept-Language":"zh-CN,zh;q=0.8","Cache-Control":"max-age=0","Connection":"keep-alive" ,"User-Agent":"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0", "Cookie": "visitkey=52562270763683935"}

conn = httplib.HTTPConnection("112.90.77.176:80")
conn.request("GET", "/extinfo/GetMobileProductInfo",urllib.urlencode({'mobile': 15226922222,'amount':10000}),headers)
r1 = conn.getresponse()
print r1.status, r1.reason
巴扎黑
巴扎黑

reply all(1)
PHPzhong
conn = httplib.HTTPConnection("112.90.77.176:80")

changed to

conn = httplib.HTTPConnection("virtual.paipai.com")
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!