python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2167字,纯文字阅读大概需要4分钟。
内容图文
![python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码](/upload/InfoBanner/zyjiaocheng/652/a82b90e5add54781a0247d761ea225b6.jpg)
#!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019年12月9日11:41:08 # @Author : shenghao/10347899@qq.com '''test with selenium's move by x,y''' from builtins import print from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By import cv2 as cv import time, datetime, random,shutil from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.touch_actions import TouchActions from selenium.webdriver.common.keys import Keys from PIL import Image import requests from io import BytesIO import cv2, time, sys,re import matplotlib.pyplot as plt import numpy as np class selenium(object): def __init__(self): self.headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"} chrome_option = webdriver.ChromeOptions() self.driver = webdriver.Chrome(executable_path="C:\Program Files\Python37\chromedriver.exe", chrome_options=chrome_option) self.driver.set_window_size(1440, 900) def visit_index(self): self.driver.get( "https://callback.58.com/antibot/verifycode?serialId=62cbf64a21ab4d309e722680c623a4e4_31ec33353c0648b7a5c97b1f2fb35976&code=22&sign=e6760461fc971994a2f3809ff536fbe9&namespace=anjuke_zufang_pc&url=.zu.anjuke.com%2Ffangyuan%2F1206610285371393%3Fisauction%3D1%26shangquan_id%3D1846") try: click_status = WebDriverWait(self.driver, 5, 1).until( EC.element_to_be_clickable((By.XPATH, "//div[@class = 'code_num']/input"))).click() html = self.driver.find_element_by_xpath("//*").get_attribute("outerHTML") rid = re.search("rid=(.*?)&", html).group(1) time.sleep(1) self.move(rid) except: pass def move(self,rid): element = self.driver.find_element_by_xpath("//div[@class = 'dvc-slider__handler']") move_list = ([100,0],[-3,0],[-4,0],[-5,0],[3,0],[2,0],[8,0],[10,0]) if element: ActionChains(self.driver).click_and_hold(on_element=element).perform() for m in move_list: ActionChains(self.driver).move_by_offset(xoffset=m[0], yoffset=m[1]).perform() time.sleep(0.2) time.sleep(2) self.driver.close() if __name__ == '__main__': h = selenium() h.visit_index()
内容总结
以上是互联网集市为您收集整理的python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码全部内容,希望文章能够帮你解决python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。