• python 2.7 windows 中文uniocde 乱码解决


    # !/usr/bin/env python
    # -*- coding: utf-8 -*-
    import urllib2
    import urllib
    import cookielib
    import json
    import httplib
    import re
    import requests
    from lxml import etree
    import StringIO
    import time
    import datetime
    import hashlib
    import sys
    reload(sys)
    import io
    # sys.stdout=io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')
    s = requests.session()
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0'
    }
    data = {
        'formmethod': 'post',
        'logfile': '/wui/theme/ecology8/page/login.jsp?templateId=3&logintype=1&gopage=',
        'loginid':'0xx',
        'logintype':'1',
        'isie':'false',
        'submit':u'登录',
        'userpassword':'xxx'
    }
    print data
    login_url = 'http://20.3.200.19/login/VerifyLogin.jsp'
    try :
     response = s.post(login_url, data=data, headers=headers,timeout=10)
     print response.content
     print response.status_code
     res= s.get('http://20.3.200.19/tailong/syslink/daohanglianjie.jsp').content
     print res
    except:
        print 'login failed'
    htmlEmt=etree.HTML(res)
    result=htmlEmt.xpath('//div/a/@href')
    print result
    print type(result)
    for x in result:
        if re.search('dcdp-admin',x):
            dcdpurl= x
    print dcdpurl
    p=re.compile('.*tgt=(.*)')
    m=p.match(dcdpurl)
    tgt= m.group(1)
    print tgt
    data={'bsOrgId':'999999998',
          'dataOrgId':'999999998',
          'dataOrgNm':'xx',
          'extentionRoles':'035136f3-cacf-4310-bdc9-04fc33ca3fef,GROUP01,0b4dc08c-689c-43f5-aa5b-04c455226b56,GROUP22',
          'orgId':'992200401',
          'orgNm':'信息开发部应用运营中心应用支持科',
          'portalCode':'xx',
           'resId':'bdd5168a',
          'roleId':'DEPT18_SUPPORT',
          'roleDesc':'总行-信息开发部_应用支持',
          'roleNm':'总行-信息开发部_应用支持',
          'rolecode':'P1110',
          'rolename':'职能序列员工-技术一类员工-总行技术一类员工',
          'ticket':tgt,
          'userNm':'xx',
          'orgNm':'信息开发部应用运营中心运营开发科',
          'userId':'xx'}
    print s.post('http://10.3.200.49:7002/dbportal-dsb/ssoLogin.do',data=data).content
    print s.get('http://10.3.200.49:7002/dbportal-dsb/index.do').content
    res1= s.get('http://10.3.253.15:7012/WebReport/ReportServer?_=1594864802744&__boxModel__=true&op=page_content&sessionID=79203&pn=1&__webpage__=true&_paperWidth=1340&_paperHeight=196&__fit__=false').content
    print type(res1)
    print res1
    htmlEmt=etree.HTML(res1)
    result=htmlEmt.xpath('//div[@heavytd="light"]')
    print result
    print type(result)
    for x in result:
        print x.text.encode('unicode_escape').decode('string-escape').decode('gbk',errors='ignore')
        print type(x.text.encode('unicode_escape').decode('string-escape').decode('gbk',errors='ignore'))
    
  • 相关阅读:
    树的定义与存储
    软件测试概论二
    软件测试概论
    抽象数据类型
    java编程总结01---20190214
    java 按行读取本文文件并存放到mongodb中
    刷题感悟
    刷题感悟- Binary Tree Path Sum
    java io与nio
    java IO 学习笔记
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348283.html
Copyright © 2020-2023  润新知