python伪装微信post提交

进行post或者get请求一个网页时返回值为:请使用微信打开页面

解决办法为在请求的头部信息加上userAgent的值来伪装微信内置浏览器去请求

url = "http://xxxxxxxx"

params = {"phone":phone,"name":name}
params = urllib.urlencode(params)

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()

转载于:https://www.cnblogs.com/str-/p/7345552.html

你可能感兴趣的:(python伪装微信post提交)