标签:
最近需要模拟游戏登陆,蛋疼
1 #coding=utf-8 2 import os 3 import urllib 4 import urllib2 5 import re 6 import cookielib 7 import json 8 9 10 headers = {} 11 headers[‘Content-Type‘] = ‘application/json; charset=utf-8‘ 12 13 values = {} 14 values["uuid"] = ‘XXXXX‘ 15 values[‘uid‘] = ‘86945‘ 16 port = ‘3002‘ 17 18 route = ‘login‘ 19 20 21 post_data = urllib.urlencode(values) 22 j_data = json.dumps(values) 23 print j_data 24 25 def jsonPost(url): 26 req = urllib2.Request(url, j_data, headers) 27 page = urllib2.urlopen(req) 28 res = page.read() 29 page.close() 30 return res 31 32 33 res = jsonPost("http://127.0.0.1:%s/%s" % (port, route)) 34 print res
标签:
原文地址:http://www.cnblogs.com/hangj/p/4720628.html