首页 > 其他分享 >word_wjuan

word_wjuan

时间:2023-08-26 09:22:22浏览次数:26  
标签:word url driver element wjuan password find browser

import random
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains

word_lianjie_download = 'div/id=divMsg'
url = 'https://www.wjx.cn/login.aspx'
s = Service("chromdriver.exe")
# driver = webdriver.Firefox() # 初始化一个火狐浏览器实例:driver
driver = webdriver.Chrome()
driver.maximize_window() # 最大化浏览器
driver.get(url) # 通过get()方法,打开一个url站点
username = driver.find_element(By.NAME, "UserName")
username.send_keys(' ')
password = driver.find_element(By.NAME, 'Password')
password.send_keys(' ')
submit_button = driver.find_element(By.NAME, 'LoginButton')
try:
drag_element = driver.find_element(By.CLASS_NAME, "nc_iconfont btn_slide")
action = ActionChains(driver)
action.click_and_hold(drag_element)
action.move_by_offset(125, 0)
action.release().perform()
except:
pass
submit_button.click()


def out_word(driver, url_wordx):
driver.get(url_wordx)
word_table = driver.find_element(By.ID, 'tbQuestion')
save_word = driver.find_element(By.NAME,'ctl04')
save_word.click()
# word_link = driver.find_element(By.ID,'divMsg')
time.sleep(15)
aa = driver.find_element(By.CLASS_NAME,'wjx_alink')
aa.click()
print(f"-------- 已生成第 {m} 个文件!")
time.sleep(3)


for n in range(1,52):
ls=[]
m=1
url_n = f'https://www.wjx.cn/NewWJX/manage/MyQuestionnaires.aspx?pageindex={n}&sortbn=t1'
driver.get(url_n)
wins = driver.window_handles
driver.switch_to.window(wins[-1])
id_w = driver.find_elements(By.XPATH,
'/html/body/div[1]/div[2]/form/div[4]/div/div/div[2]/div/div[2]//dl/dd/div[1]/dl[1]/dd/a')
print("=" * 10 + f'第{n}页' + "=" * 10)
time.sleep(random.random())
for i in id_w:
url_word = i.get_attribute('href')
url_words = url_word.replace('designstart', 'printq')
print(url_words)
ls.append(url_words)
for url_words in ls:
out_word(driver,url_words)
m+=1
m=1
print('--------- 程序完成! ---------')



# driver.quit()
# while browser.current_url != expected_url:
# time.sleep(1)
#
# if 'Login successful' in browser.page_source:
# print('Login successful')
# else:
# print('Login failed')
#

def yanzheng():
from selenium import webdriver
import time
import re
from PIL import Image
import pytesseract

# 获取动态密码


def get_dynamic_password():
# TODO: 实现获取动态密码的方法
pass
# 打开浏览器,并访问登录页面
browser = webdriver.Chrome()
browser.get('https://www.example.com/login')
# 输入用户名和密码
username = browser.find_element_by_name('username')
username.send_keys('your username')
password = browser.find_element_by_name('password')
password.send_keys('your password')

# 处理验证码
while True:
if 'captcha' in browser.page_source:
captcha_image = browser.find_element_by_xpath('//img[@alt="captcha"]')
captcha_image.screenshot('captcha.png')
captcha_input = browser.find_element_by_name('captcha')
captcha_input.clear()
image = Image.open('captcha.png')
code = pytesseract.image_to_string(image)
code = re.findall('\d+', code)[0]
captcha_input.send_keys(code)
submit_button = browser.find_element_by_id('login-submit')
submit_button.click()
time.sleep(3)
else:
break

# 处理动态密码
while True:
if 'dynamic-password' in browser.page_source:
dynamic_password = get_dynamic_password()
dynamic_password_input = browser.find_element_by_name('dynamic-password')
dynamic_password_input.send_keys(dynamic_password)
submit_button = browser.find_element_by_id('login-submit')
submit_button.click()
time.sleep(3)
else:
break

# 等待跳转到目标页面,检查是否成功登录
expected_url = 'https://www.example.com/home'
while browser.current_url != expected_url:
time.sleep(1)

if 'Login successful' in browser.page_source:
print('Login successful')
else:
print('Login failed')

标签:word,url,driver,element,wjuan,password,find,browser
From: https://www.cnblogs.com/QQ-77Ly/p/17658351.html

相关文章

  • python将word文档转为pdf
    用python处理word文档,将word文档转换为pdf文档,可以使用docx2pdf模块。使用pip安装即可。关键代码如下:fromdocx2pdfimportconvertconvert("需要转换的word文档","生成的pdf文档")如果需要批量进行转换的话,最好是每一个后面加点延时,并做好异常处理。......
  • FCKEditor 从word中复制内容带多张图片
    ​ 图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码目前限chrome浏览器使用首先以um-editor的二进制流保存为例:打开umeditor.js,找到UM.plugins['autoupload'],然后找到autoUploadHandler方法,注释掉其中的代码。加入下面的代码://判断剪......
  • xhEditor 从word中复制内容带多张图片
    ​ 这种方法是servlet,编写好在web.xml里配置servlet-class和servlet-mapping即可使用后台(服务端)java服务代码:(上传至ROOT/lqxcPics文件夹下)<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@     page contentType="text/html;cha......
  • TinyMCE 从word中复制内容带多张图片
    ​ 在之前在工作中遇到在富文本编辑器中粘贴图片不能展示的问题,于是各种网上扒拉,终于找到解决方案,在这里感谢一下知乎中众大神以及TheViper。通过知乎提供的思路找到粘贴的原理,通过TheViper找到粘贴图片的方法。其原理为一下步骤:监听粘贴事件;【用于插入图片】获取光标位置;【......
  • HTML编辑器 从word中复制内容带多张图片
    ​ 如何做到ueditor批量上传word图片?1、前端引用代码<!DOCTYPE html PUBLIC "-//W3C//DTDXHTML1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>......
  • WPF PasswordBox控件的使用
    在做登陆框的时候使用到PasswordBox,PasswordBox并不能像TextBox一样通过Binding就可以实现MVVM,需要用到依赖属性。 LoginView文件的代码:<StackPanelGrid.Row="0"Orientation="Horizontal"Margin="5"><TextBlockText="Username:"Width=&qu......
  • Navicat Premium保存密码失败:Failed to save password Error code: -34018
    卸载卸载干净后重装15.0.29或之后的版本,卸载参见:https://download.csdn.net/blog/column/9651437/103915601:sudorm-Rf/Applications/Navicat\Premium.appsudorm-Rf/private/var/db/BootCaches/CB6F12B3-2C14-461E-B5A7-A8621B7FF130/app.com.prect.NavicatPremium.play......
  • 用Python制作一个PDF转Word工具(V2.1)
    用Python制作一个PDF转Word工具工具:Python3.9.13,VSCode1.73.1,pdf2docx0.5.6,tkinter,Win10HomePDF文件不易编辑,想要编辑需要转成Word,但网上的工具很多要充VIP,所以今天我们就来做个PDF转Word工具。首先先安装第三方库:```bashpipinstalltkinter```导入库:```python#coding=utf-8im......
  • springBoot 整合 poi 导出带有复杂表格(合并表格)的word文件
    1.Maven依赖见上一篇文章直接贴源码如下:packagecom.mingx.pms.web.system.file;importcn.hutool.core.date.DateUtil;importcom.mingx.pms.constant.SystemInfo;importcom.mingx.pms.entities.workplan.plan.vo.WorkPlanDetailExportVO;importcom.mingx.pms.entities......
  • vue eslint 报错 error “Component name “*****“ should always be multi-word”,该
    出现的问题: 在 vue-cli 创建的项目中,创建文件并命名后,会报  “Componentname"*****"shouldalwaysbemulti-word”  报错;报错截图示例如下:Componentname"******"shouldalwaysbemulti-word.eslintvue/multi-word-component-names报错的原因: 在组件命......