国家企业信用信息公示系统验证码破解(五)
可能有些人看了前面四篇帖子还是没弄清楚应该怎么去编写代码,没关系,这边已经准备好了完整代码:
# -*- coding: utf-8 -*-
"""
@author: yanglei
Edited on 2019年2月23日
"""
try:
from selenium import webdriver
except:
print(__file__, "needs selenium.")
raise SystemExit
try:
import pyautogui
except:
print(__file__, "needs pyautogui.")
raise SystemExit
import time
import ubpa.iimg as iimg
import Supermandama
import re
companies=['江苏众悦商业管理有限公司', '南京百奥贸易有限公司', '南京鼎控贸易有限公司', '南京君晟钢铁有限公司', '南京雷坤贸易有限公司', '南京明宇医药技术发展有限公司']
def huadong():
imgpath = iimg.capture_image(win_title=r'国家企业信用信息公示系统 - Google Chrome',win_text=r'',left_indent=792,top_indent=424,width=317,height=193,waitfor=30)
location = Supermandama.run_supermandama(imgpath)['result']
print('location:',location)
if type(location) == str:
location = location.split(';')
if location.count('') == 1:
del location[-1]
pyautogui.moveTo(840, 630)
pyautogui.dragTo(807+int(location[0].split(',')[0]), 640, 1, pyautogui.easeOutQuad)
time.sleep(5)
def dianji():
imgpath = iimg.capture_image(win_title=r'国家企业信用信息公示系统 - Google Chrome',win_text=r'',left_indent=756,top_indent=337,width=388,height=442,waitfor=30)
location = Supermandama.run_supermandama(imgpath)['result']
print('location:',location)
if type(location) == str:
location = location.split(';')
if location.count('') == 1:
del location[-1]
for point in location:
if point:
pyautogui.moveTo(750+int(point.split(',')[0]),330+int(point.split(',')[1]), duration=1)
pyautogui.click(750+int(point.split(',')[0]),330+int(point.split(',')[1]))
pyautogui.moveTo(780+304,410+378, duration=1)
pyautogui.click(780+304,410+378)
time.sleep(5)
def init():
browser = webdriver.Chrome()
browser.get('http://www.gsxt.gov.cn/index.html')
browser.maximize_window()
browser.implicitly_wait(30)
time.sleep(1)
return browser
def judge_yzm_type(source, browser):
if re.findall(r'<span class="ads-sci-title">', source): # 通过验证,进入查询页面
print('进入查询结果页面')
time.sleep(2)
browser.back()
print('返回首页')
elif re.findall(r'<div class="geetest_slider geetest_ready">', source): # 滑动验证码
print('滑动验证码')
huadong()
time.sleep(5)
source = browser.page_source
judge_yzm_type(source, browser)
elif re.findall(r'<img class="geetest_item_img"',source): # 点击验证码
print('点击验证码')
dianji()
time.sleep(5)
source = browser.page_source
judge_yzm_type(source, browser)
else: # 无反应
browser.refresh()
time.sleep(2)
yzm(browser)
def yzm(browser):
for i in companies:
input = browser.find_element_by_id("keyword")
button = browser.find_element_by_id("btn_query")
input.send_keys(i)
button.click()
time.sleep(5)
source = browser.page_source
judge_yzm_type(source, browser)
time.sleep(5)
if __name__ == "__main__":
yzm(init())
2ad65a5ef2284a4ab82752687a115e38_Guoxin.py ,记得删除最后一行
然后去这边http://support.i-search.com.cn/article/1552830841065 下载 Supermandama.py,并且修改第 52 与 53 行的账号密码,删除最后一行的------WebKitFormBoundarygwaBBkUbRLYqqTub--
,把文件名 Supermandama 前面的内容删除,把两个.py 文件放在同一个文件夹下,然后调用 python 运行 Guoxin.py 即可
没了,完结啦
还有后续嘛?
我是图腾收集者
你不应该掉大家胃口,你是坏人