python 解返回Json 为字典
来源:互联网 发布:淘宝联盟微博设置方法 编辑:程序博客网 时间:2024/06/05 15:06
# !/usr/bin/env python# -*- coding: utf-8 -*-import urllib2import urllibimport cookielibimport jsonimport httplibimport timeimport reimport osimport requestss=requests.session()print s.headersurl = "https://www.awfae.com/validcode/generate-validcode.do"r = s.get(url)r=r.content#print sprint type(r)print rfilename='E:\image.jpg'local = open(filename,'wb')local.write(r)local.close()print "登录二维码已经下载到本地"+"["+filename+"]"##打开图片os.system("start %s" % filename);code = raw_input('输入验证码: ')print code;print len(code)login_url='https://www.awfae.com/business/dispatch_post.do'data = {'action':'doLogin','userName': '18072722237','followId':'','userPass':'79e8fe923f031f46221a9283d0c9263a','validCode':code}#data = urllib.urlencode(data)headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',}response = s.post(login_url, data=data,headers=headers)print responseprint response.status_codeprint response.content#返回的跳转URLprint response.urlrepurl='https://www.awfae.com/web/auth?method=%2Fclient%2Fassetlist&platform=web&_=1508406995591'r= s.get(repurl,headers=headers)r = r.contentprint rprint type(r)print type(r)text = json.loads(r)print type(text)print text['data']print type( text['data'])https://www.awfae.com/account/myAccount.html?subPage=/account/dashBoard.html&uuid=20150925104158452da9e0c7979d4438&{"data":[{"disableBuyAmount":0,"wzeFrozenBalance":0E-10,"frozenWithdraw":0E-10,"clientSn":1662,"frozenPay":0E-10,"totalInvestBalance":0E-10,"wzeAvailableBalance":1.9000000000,"currentInvestBalance":0,"availableBalance":6.1000000000,"todayCashLimit":true,"totalAvailableBalance":8.0000000000,"exchangeName":"温金所","canRechargeAmount":0,"exchangeCode":"10000001"},{"disableBuyAmount":0,"wzeFrozenBalance":0E-10,"frozenWithdraw":0E-10,"clientSn":1662,"frozenPay":0E-10,"totalInvestBalance":0E-10,"wzeAvailableBalance":0E-10,"currentInvestBalance":0,"availableBalance":0E-10,"todayCashLimit":true,"totalAvailableBalance":0E-10,"exchangeName":"镇金所","canRechargeAmount":0,"exchangeCode":"10000002"}],"retCode":"0000","retMsg":"查询成功"}<type 'str'><type 'str'><type 'dict'>[{u'disableBuyAmount': 0, u'totalAvailableBalance': 8.0, u'wzeFrozenBalance': 0.0, u'canRechargeAmount': 0, u'exchangeCode': u'10000001', u'clientSn': 1662, u'frozenWithdraw': 0.0, u'currentInvestBalance': 0, u'todayCashLimit': True, u'availableBalance': 6.1, u'exchangeName': u'\u6e29\u91d1\u6240', u'wzeAvailableBalance': 1.9, u'totalInvestBalance': 0.0, u'frozenPay': 0.0}, {u'disableBuyAmount': 0, u'totalAvailableBalance': 0.0, u'wzeFrozenBalance': 0.0, u'canRechargeAmount': 0, u'exchangeCode': u'10000002', u'clientSn': 1662, u'frozenWithdraw': 0.0, u'currentInvestBalance': 0, u'todayCashLimit': True, u'availableBalance': 0.0, u'exchangeName': u'\u9547\u91d1\u6240', u'wzeAvailableBalance': 0.0, u'totalInvestBalance': 0.0, u'frozenPay': 0.0}]<type 'list'>
阅读全文
0 0
- python 解返回Json 为字典
- Python处理json字符串转化为字典
- Python处理json字符串转化为字典
- Python处理json字符串转化为字典
- 字典转化为 json 字符串
- JSON字符串转化为字典
- python 解接口返回的json字符串
- python mysql 返回json
- python bottle json 返回
- Python的字典和JSON
- 让python的mysqldb返回的结果集为字典类型
- 让python的mysqldb返回的结果集为字典类型
- python字典中文乱码,将其转换为json格式输出
- SpringMvc 返回数据为json
- Python -- 字典转换为列表
- Python:列表值为字典
- Python 列表转换为字典
- jquery中json数据转换为字典
- tomcat的虚拟目录的映射
- gitlab忘记管理员的密码解决方法
- Android那些事儿之自定义进度条
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 的解决办法
- nginx+uwsgi+Django配置
- python 解返回Json 为字典
- Java抽象类联系(第六周)
- vue-cli项目本地代理实现跨域请求
- 企鹅号试运营期间,账号为什么会被封停?
- Ubuntu 安装 Pepper Flash Player
- 入坑Linux的一点原因
- 1-1·Linux简介、什么是Linux
- codeforces 864B 之 Polycarp and Letters
- Android 4.4以上第三方应用不能插入短信的解决办法