zoukankan      html  css  js  c++  java
  • python 解返回Json 为字典

    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import urllib2
    import urllib
    import cookielib
    import json
    import httplib
    import time
    import re
    import os
    import requests
    s=requests.session()
    print s.headers
    url = "https://www.awfae.com/validcode/generate-validcode.do"
    r = s.get(url)
    r=r.content
    #print s
    print type(r)
    print r
    filename='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  response
    print response.status_code
    print response.content
    #返回的跳转URL
    print response.url
    repurl='https://www.awfae.com/web/auth?method=%2Fclient%2Fassetlist&platform=web&_=1508406995591'
    r= s.get(repurl,headers=headers)
    r = r.content
    print r
    print 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'u6e29u91d1u6240', 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'u9547u91d1u6240', u'wzeAvailableBalance': 0.0, u'totalInvestBalance': 0.0, u'frozenPay': 0.0}]
    <type 'list'>

  • 相关阅读:
    智能家居——安全信息收集(一)
    PMP软件管理之路——站在巨人的肩膀上(一)
    Linux——信息收集(二)Nikto网页服务器扫描器
    XML约束(3)
    xml基本语法(2)
    xml概述(1)
    ajax接受json响应
    ajax接受json响应(讲义)
    json与xml的比较
    零碎小技能
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349501.html
Copyright © 2011-2022 走看看