zoukankan      html  css  js  c++  java
  • 登录+获取驾驶本违章信息

    #coding:utf-8
    import os
    import re
    import ydm
    import time
    import requests





    class Driver:
    s = requests.session()
    provice = ''

    def __init__(self,number,password):
    self.number = number
    self.password = password


    def login(self,nums=3,times=60):
    head = {
    'User-Agent': "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5"
    }
    capcha_url = 'https://gab.122.gov.cn/sso/captcha?nocache=' + str(int(time.time() * 1000))
    img = self.s.get(capcha_url)
    with open('capcha.jpg', 'wb')as f:
    f.write(img.content)

    '''
    云打码验证图片
    username = '云打码账号'
    password = '密码'
    appid = 4359
    appkey = '0715011dad66b60956de51723d5509c2'
    filename = 'capcha.jpg'
    codetype = 1004
    timeout = 60
    if (username == 'username'):
    print('请设置好相关参数再测试')
    else:
    yundama = ydm.YDMHttp(username, password, appid, appkey)
    balance = yundama.balance()
    print('balance: %s' % balance)
    # 开始识别,图片路径,验证码类型ID,超时时间(秒),识别结果
    cid, result = yundama.decode(filename, codetype, timeout)
    print('验证码为:',result)
    code = result
    '''
    os.system('capcha.jpg')
    code = input('验证码::::::')
    try:
    post_data = {
    'appid': '000000',
    'usertype': '1',
    'username': self.number,
    'password': self.password,
    'captcha': str(code)
    }
    dbs = self.s.post('https://gab.122.gov.cn/sso/login/db', data=post_data, allow_redirects=False, headers=head,timeout=times)
    time.sleep(1)
    log_1 = self.s.get(dbs.headers['Location'], headers=head, allow_redirects=False,timeout=times)
    num = re.search('.cn(.*?)/m/.*?', log_1.headers['Location']).group(1)
    print(log_1.headers['Location'])
    # print(num)
    print(log_1.headers['Location'].replace(num, ''))
    log_2 = self.s.get(log_1.headers['Location'].replace(num, ''), allow_redirects=False, headers=head,timeout=times)
    log_s = self.s.get(log_2.headers['Location'], allow_redirects=False, headers=head,timeout=times)
    log_ss = self.s.get(log_s.headers['Location'], allow_redirects=False, headers=head,timeout=times)
    ast = self.s.get(log_ss.headers['Location'], allow_redirects=False, headers=head,timeout=times)
    log_t1 = self.s.get(ast.headers['Location'], allow_redirects=False, headers=head,timeout=times)
    log_t2 = self.s.get(log_t1.headers['Location'], allow_redirects=False, headers=head,timeout=times)
    jes = self.s.get(log_t2.headers['Location'], allow_redirects=False, headers=head,timeout=times)
    # global provice
    self.provice = re.search('http://(w+).122.gov.cn.*?', jes.url).group(1)
    print(jes.text)
    print(self.provice)
    except Exception as e:
    print(e)
    print('5秒后重试')
    time.sleep(5)
    if nums > 0:
    print('还有', nums, '次机会....')
    return self.login(nums - 1)
    else:
    exit()




    d = Driver('驾驶本编号','密码')
    d.login()
  • 相关阅读:
    sgdisk基本用法
    影响性能的关键部分-ceph的osd journal写
    SSD固态盘应用于Ceph集群的四种典型使用场景
    Ceph在OpenStack中的地位
    Ceph的工作原理及流程
    Ceph系统的层次结构
    SharePoint运行状况分析器有关磁盘空间不足的警告
    Microsoft Exchange本地和Exchange Online可以与第三方服务共享
    SharePoint Server 2016 WEB 网站浏览器支持
    禁用自动映射的 Exchange 邮箱
  • 原文地址:https://www.cnblogs.com/zhangheng1/p/8649649.html
Copyright © 2011-2022 走看看