1 Star 0 Fork 0

故事里的大魔王/My_pycharm_project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
爬取青大教务.py 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
故事里的大魔王 提交于 2023-06-12 21:46 +08:00 . pycharm的一些小练习
from selenium import webdriver
from selenium.webdriver.common.by import By
from PIL import Image
import ddddocr
import time
bro = webdriver.Edge()
bro.get('http://jw.qdu.edu.cn/homepage/index.do')
bro.save_screenshot('full_page.png')
code_img_ele = bro.find_element(By.ID,'jcaptcha')
location = code_img_ele.location
size = code_img_ele.size
rangle = (
1.5*int(location['x']),1.5*int(location['y']),1.5*int(location['x']+size['width']),1.5*int(location['y']+size['height']))
i = Image.open('./full_page.png')
name = './coding_result.png'
frame = i.crop(rangle)
frame.save(name)
ocr = ddddocr.DdddOcr()
with open('coding_result.png','rb') as fp:
img_data = fp.read()
pass
res = ocr.classification(img_data)
account = bro.find_element(By.XPATH,'//*[@id="login"]/tbody/tr[4]/td/input')
account.send_keys('2021200218')
password = bro.find_element(By.XPATH,'//*[@id="login"]/tbody/tr[6]/td/input')
password.send_keys('11.100.11.10.1')
security_code = bro.find_element(By.XPATH,'//*[@id="login"]/tbody/tr[8]/td/input')
security_code.send_keys(res)
log_in = bro.find_element(By.CLASS_NAME,'button')
log_in.click()
time.sleep(10)
bro.quit()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/yu_fengguang/pychar-mini-exercise.git
[email protected]:yu_fengguang/pychar-mini-exercise.git
yu_fengguang
pychar-mini-exercise
My_pycharm_project
master

搜索帮助