为了账号安全,请及时绑定邮箱和手机立即绑定

python实现虾米音乐自动签到脚本

python实现虾米音乐自动签到脚本

慕尼黑8549860 2019-04-09 20:25:46
初学python以及编程,尝试写这样一个脚本,待成功后才会继续完善。现在想要实现登陆。问题:请问我这个代码哪儿出了问题?登陆不成功。headers和postData要写哪些出来,我用HttpFox抓包的。postData有perfect和raw版本,我在写的时候用哪个?感谢!header有如下几项:(Request-Line)POST/member/login?callback=jQuery191069041835273338_1398059175342HTTP/1.1Hostlogin.xiami.comUser-AgentMozilla/5.0(X11;Ubuntu;Linuxx86_64;rv:28.0)Gecko/20100101Firefox/28.0Accepttext/javascript,application/javascript,application/ecmascript,application/x-ecmascript,*/*;q=0.01Accept-Languagezh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3Accept-Encodinggzip,deflateContent-Typeapplication/x-www-form-urlencoded;charset=UTF-8X-Requested-WithXMLHttpRequestRefererhttps://login.xiami.com/member/login?spm=a1z1s.6843761.226669510.8.mgS3tyContent-Length174Cookie__utma=251084815.807798752.1397902515.1398051611.1398059164.8;__utmz=251084815.1397902515.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);_xiamitoken=5d6acda6813fcfb509c692f961c1db91;_unsign_token=adb241a1ca1e9d88841a8b03f1dfbf0a;CNZZDATA921634=cnzz_eid%3D290074860-1397902517-null%26ntime%3D1398059175%26cnzz_a%3D16%26sin%3Dhttp%253A%252F%252Fwww.xiami.com%252F%26ltime%3D1398044904939%26rtime%3D1;CNZZDATA2629111=cnzz_eid%3D953933079-1397902517-null%26ntime%3D1398059175%26cnzz_a%3D16%26sin%3Dhttp%253A%252F%252Fwww.xiami.com%252F%26ltime%3D1398044905317%26rtime%3D1;__gads=ID=4810f3a98f707097:T=1397902585:S=ALNI_MZIeFDBRyd7UMnR4vzSVgiPocjL1Q;__utmb=251084815.3.10.1398059164;__utmc=251084815;t_sign_auth=3Connectionkeep-alivePragmano-cacheCache-Controlno-cache而postData有如下几项:_xiamitoken5d6acda6813fcfb509c692f961c1db91donehttp%3A%2F%2Fwww.xiami.comfromwebhavanaIdemail被我隐去(原始状态)password被我隐去(原始状态)submit登录postData的raw版本:_xiamitoken=5d6acda6813fcfb509c692f961c1db91&done=http%253A%252F%252Fwww.xiami.com&from=web&havanaId=&email=810233438%40qq.com&password=密码隐去(原始状态)&submit=%E7%99%BB+%E5%BD%95#!/usr/bin/envpython3#-*-coding:utf-8-*-'''Asimplepyusedtosigninxiami@author:caosz11@mails.tsinghua.edu.cn'''importurllibfromurllibimportparsefromurllibimportrequestheaders={'User-Agent':'Mozilla/5.0(X11;Ubuntu;Linuxx86_64;rv:28.0)Gecko/20100101Firefox/28.0','Referer':'https://login.xiami.com/member/login?spm=a1z1s.6843761.226669510.8.mgS3ty'}postData={'email':'XXX@qq.com','password':'XXX','done':'http%253A%252F%252Fwww.xiami.com','submit':'E7%99%BB+%E5%BD%95','_xiamitoken':'5d6acda6813fcfb509c692f961c1db91'}postData=urllib.parse.urlencode(postData)postData=postData.encode('utf-8')print('Logging...')req=urllib.request.Request('http://xiami.com/member/login',postData,headers)result=urllib.request.urlopen(req).read()result=result.decode('utf-8')print(result)
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 632 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信