Qingdao Gov Facial Mask Appointment

import pytesseract
from pyfiglet import Figlet
import requests
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Chrome()

# driver.get('http://www.baidu.com') #vux-x-input-twq0s
# driver.get('file:///Volumes/DATA/python_projects/kz/口罩预约/顺丰预约.html')
# driver.get('file://F:\\PyCharmProjects\\facial-mask-appointment\\口罩预约\\顺丰预约.html')
# driver.get('file://F:\\PyCharmProjects\\facial-mask-appointment\\快递预约2\\快递预约.html')
driver.get('http://kzyynew.qingdao.gov.cn:81/dist/index.html#/preOrder')
# driver.get('http://kzyynew.qingdao.gov.cn:81/dist/index.html#/SFOrder')

link_list = [
    {'name': '钟灵',
     'tel': '1856130xxx0',
     'id_number': '3707251xxxxxxxxxxx5'},
    {'name': '钟灵',
     'tel': '1856130xxx0',
     'id_number': '3707251xxxxxxxxxxx5'},
]


def clear_input(input):
    ActionChains(driver).move_to_element(input).send_keys(Keys.CONTROL, "a")
    ActionChains(driver).move_to_element(input).send_keys(Keys.DELETE)

def fill_link_data(name, tel, id_number):
    try:
        check_button = driver.find_element_by_xpath('//*[@id="app"]/div/div/div[3]/div/div/div/i[3]')
        check_button.click()
    except:
        pass

    weuis = driver.find_elements_by_xpath("//input")
    # 姓名
    # print(weuis[0])
    weuis[0].clear()
    clear_input(weuis[0])
    # weuis[0].sendKeys(Keys.CONTROL, "a")
    # weuis[0].sendKeys(Keys.DELETE)
    weuis[0].send_keys(name)
    # 电话
    weuis[1].clear()
    clear_input(weuis[1])
    weuis[1].send_keys(tel)
    # 身份证号
    weuis[2].clear()
    clear_input(weuis[2])
    weuis[2].send_keys(id_number)
    #
    selects = driver.find_elements_by_xpath("//select")
    selects[0].send_keys('李沧区')
    selects[1].send_keys('浮山路街道办事处')

    driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div/div[6]/div[2]/textarea').clear()
    driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div/div[6]/div[2]/textarea').send_keys(
        '李沧区')

import pytesseract
from pyfiglet import Figlet
import requests
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Chrome()

# driver.get('http://www.baidu.com') #vux-x-input-twq0s
# driver.get('file:///Volumes/DATA/python_projects/kz/口罩预约/顺丰预约.html')
# driver.get('file://F:\\PyCharmProjects\\facial-mask-appointment\\口罩预约\\顺丰预约.html')
# driver.get('file://F:\\PyCharmProjects\\facial-mask-appointment\\快递预约2\\快递预约.html')
driver.get('http://kzyynew.qingdao.gov.cn:81/dist/index.html#/preOrder')
# driver.get('http://kzyynew.qingdao.gov.cn:81/dist/index.html#/SFOrder')

link_list = [
    {'name': '钟灵',
     'tel': '1856130xxx0',
     'id_number': '3707251xxxxxxxxxxx5'},
    {'name': '钟灵',
     'tel': '1856130xxx0',
     'id_number': '3707251xxxxxxxxxxx5'},
]


def clear_input(input):
    ActionChains(driver).move_to_element(input).send_keys(Keys.CONTROL, "a")
    ActionChains(driver).move_to_element(input).send_keys(Keys.DELETE)

def fill_link_data(name, tel, id_number):
    try:
        check_button = driver.find_element_by_xpath('//*[@id="app"]/div/div/div[3]/div/div/div/i[3]')
        check_button.click()
    except:
        pass

    weuis = driver.find_elements_by_xpath("//input")
    # 姓名
    # print(weuis[0])
    weuis[0].clear()
    clear_input(weuis[0])
    # weuis[0].sendKeys(Keys.CONTROL, "a")
    # weuis[0].sendKeys(Keys.DELETE)

    weuis[0].send_keys(name)
    # 电话
    weuis[1].clear()
    clear_input(weuis[1])
    weuis[1].send_keys(tel)
    # 身份证号
    weuis[2].clear()
    clear_input(weuis[2])
    weuis[2].send_keys(id_number)
    #
    selects = driver.find_elements_by_xpath("//select")
    selects[0].send_keys('李沧区')
    selects[1].send_keys('浮山路街道办事处')

    driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div/div[6]/div[2]/textarea').clear()
    driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div/div[6]/div[2]/textarea').send_keys(
        '李沧区')


def send_request(driver, url, params, method='POST'):
    if method == 'GET':
        parm_str = ''
        for key, value in params.items():
            parm_str = parm_str + key + '=' + str(value) + '&'
        if parm_str.endswith('&'):
            parm_str = '?' + parm_str[:-1]
        driver.get(url + parm_str)
    else:
        jquery = open('jquery.js', "r").read()
        driver.execute_script(jquery)
        ajax_query = '''
                    $.ajax('%s', {
                    type: '%s',
                    data: %s, 
                    crossDomain: true,
                    xhrFields: {
                     withCredentials: true
                    },
                    success: function(){}
                    });
                    ''' % (url, method, params)

        ajax_query = ajax_query.replace(" ", "").replace("\n", "")
        resp = driver.execute_script("return " + ajax_query)


def threshold_binary(src):
    # 把BGR图像转化成灰度图像
    src = cv.imread(src)
    gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
    # 获得灰度直方图以便调整算法的使用
    plt.hist(src.ravel(), 256, [0, 256])
    plt.show()
    # 几种二值化方法
    ret, binary = cv.threshold(gray, 50, 255, cv.THRESH_BINARY)  # 指定阈值50
    print("二值阈值: %s" % ret)
    # cv.imshow("threshold_binary", binary)
    cv.imwrite('cv.png', binary)
    ret_otsu, binary_otsu = cv.threshold(gray, 0, 255, cv.THRESH_BINARY | cv.THRESH_OTSU)
    print("二值阈值_otsu: %s" % ret_otsu)
    cv.imwrite('cv2.png', binary_otsu)
    # cv.imshow("threshold_binary_otsu", binary_otsu)
    ret_tri, binary_tri = cv.threshold(gray, 0, 255, cv.THRESH_BINARY | cv.THRESH_TRIANGLE)
    print("二值阈值_tri: %s" % ret_tri)


def cov_image():
    text = pytesseract.image_to_string(Image.open('/Volumes/DATA/python_projects/kz/captcha.png'),
                                       lang='chi_sim')
    print(text)


def image_to_text():
    url = "http://127.0.0.1:6000/b"
    captcha_url = 'http://kzyynew.qingdao.gov.cn:81/kz/captcha'
    for i in range(10):
        urllib.request.urlretrieve(captcha_url, 'captcha/' + str(i) + '.jpg')
        im = cv.imread('captcha/' + str(i) + '.jpg')
        im2 = cv.resize(im, (100, 60), )
        cv.imwrite('captcha/' + str(i) + '.jpg', im2)
        files = {'image_file': ('captcha100.jpg', open('captcha/' + str(i) + '.jpg', 'rb'), 'application')}
        r = requests.post(url=url, files=files)
        print('captcha/' + str(i) + '.jpg')
        print(r.text)


def rec_captcha():
    captcha = driver.find_element_by_xpath('//*[@id="app"]/div/div/div[1]/div/div[8]/img')
    captcha_url = captcha.get_attribute('src')
    print(captcha_url)
    urllib.request.urlretrieve(captcha_url, 'captcha.png')


def show_usage():
    print('*' * 100)
    f = Figlet(font='slant')
    print(f.renderText('obaby@mars'))
    print('Qingdao Gov Facial Mask Appointment')
    print('Facial Mask Appointment by obaby')
    print('Blog: http://www.h4ck.org.cn')
    print('*' * 100)


if __name__ == '__main__':
    # rec_captcha()
    # threshold_binary('/Volumes/DATA/python_projects/kz/captcha.png')
    # cov_image()
    show_usage()
    # send_request(driver,'http://kzyynew.qingdao.gov.cn:81/kz/addSforder?capval=QVBU',params)
    # print(image_to_text())
    con = input('[*] 页面加载完成,点击同意之后回车继续')
    for person in link_list:
        fill_link_data(person['name'], person['tel'], person['id_number'])
        con = input('[*] 完成提交之后回车继续进行下一项提交')
        print('~' * 100)
        driver.refresh()
        con = input('[*] 页面加载完成,点击同意之后回车继续')

基于selenium的自动预约口罩代码,现在相关网址已经下线。

☆版权☆

* 网站名称:obaby@mars
* 网址:https://h4ck.org.cn/
* 个性:https://oba.by/
* 本文标题: 《Qingdao Gov Facial Mask Appointment》
* 本文链接:https://image.h4ck.org.cn/2020/04/7034
* 短链接:https://oba.by/?p=7034
* 转载文章请标明文章来源,原文标题以及原文链接。请遵从 《署名-非商业性使用-相同方式共享 2.5 中国大陆 (CC BY-NC-SA 2.5 CN) 》许可协议。


You may also like

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注