進行post或者get請求一個網頁時返回值爲:請使用微信打開頁面瀏覽器
解決辦法爲在請求的頭部信息加上userAgent的值來假裝微信內置瀏覽器去請求微信
url = "http://xxxxxxxx"post
params = {"phone":phone,"name":name}
params = urllib.urlencode(params)ui
req_header = {"User-Agent":"Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255"}
req = urllib2.Request(url,params,req_header)
res = urllib2.urlopen(req)
res = res.read()url