1
回答
小米网新建收货地址失败
科大讯飞通用文字识别100000次/天免费使用。立即申请   
#encoding=utf-8  
import urllib2,re,os,thread,time,urllib,cookielib
sign=''
def getsign():
    content=urllib2.urlopen('https://account.xiaomi.com/pass/serviceLogin').read()
    qs=re.findall(r'var qs = encodeURIComponent\("(.*?)"',content)
    sign1=re.findall(r'var sign = encodeURIComponent\("(.*?)"',content)
    print sign1[0]
    global sign
    sign=sign1[0]
def login(user,pwd):
    global sign
    global opener
    cj = cookielib.CookieJar()
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj));
    urllib2.install_opener(opener);
    url='https://account.xiaomi.com/pass/serviceLoginAuth2'
    #post_data=urllib.urlencode('user='+user+'&_json=true&pwd='+pwd+'&sid=passport&_sign='+sign[0]+'&callback=https%3A%2F%2Faccount.xiaomi.com&qs=%3Fsid%3Dpassport')
    post_data = urllib.urlencode({'user':user, '_json':'true', 'pwd': pwd, 'callback':'https://account.xiaomi.com', 'sid':'passport', 'qs':'%3Fsid%3Dpassport', '_sign':sign})
    #print post_data
    req = urllib2.Request(url, post_data)
    content=urllib2.urlopen(req).read()
    print content.find('userId'),user
def change_add():
    global opener
    urllib2.install_opener(opener);
    url='http://order.xiaomi.com/user/address'
    post_data=urllib.urlencode({'userAddress[consignee]':'雷军',
                                'userAddress[country]':'1',
                                'userAddress[province]':'20',
                                'userAddress[city]':'235',
                                'userAddress[district]':'2219',
                                'userAddress[address]':'华强北桑达工业区',
                                'userAddress[zipcode]':'518033',
                                'userAddress[tel]':'15813855555'
                                })
    req = urllib2.Request(url,post_data) content=urllib2.urlopen(req).read()
    print content.find('5555')
getsign()
login('dengcpao956@sohu.com','juan155970')
change_add()

登陆小米网然后新建一个收货地址,不知道为什么新建收货地址失败呢,求高手帮忙看看,谢谢。




举报
郁闷龙
发帖于4年前 1回/734阅
顶部