python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码
#!/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 selenium4 模拟点击+拖动+保存验证码 测试对象+以验证码的返回ID保存命名 58同城验证码
#!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019/12/5 17:30 # @Author : shenghao/10347899@qq ...
- python selenium3 模拟点击+拖动+保存验证码 测试对象 58同城验证码
#!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019/12/5 17:30 # @Author : shenghao/10347899@qq ...
- python selenium2 模拟点击+拖动 测试对象 58同城验证码
#!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019/12/5 17:30 # @Author : shenghao/10347899@qq ...
- python selenium1 模拟点击 测试对象 58同城验证码
#!/usr/bin/python# -*- coding: UTF-8 -*-# @Time : 2019/12/5 17:30# @Author : shenghao/10347899@qq.co ...
- 如何使用python来模拟鼠标点击(将通过实例自动化模拟在360浏览器中自动搜索"python")
一.准备工作: 安装pywin32,后面开发需要pywin32的支持,否则无法完成与windows层面相关的操作. pywin32的具体安装及注意事项: 1.整体开发环境: 基于windows7操作系 ...
- Android后台监控指定app的输入内容,抢红包,模拟点击原理
Android开启辅助功能之后可以用AccessibilityService 去后台监控指定的app的输入内容,也可以监控到app的动作 以及通知栏的动作, 抢红包其实就根据通知栏出现了红包的通知消息 ...
- 【android】模拟点击某个指定坐标作用在View上
/** * 模拟点击某个指定坐标作用在View上 * @param view * @param x * @param y */ public void clickView(View view,floa ...
- Python使用selenium模拟点击(一)
本文适合有点Python基础阅读,(没基础的话,相对的比较蒙蔽,争取能让小白能一步一步跟上来) 2019-03-05 14:53:05 前几天由于需要到一个网站进行签到~~听说Python能够模拟请求 ...
- python 模拟点击微信
from PyQt5 import QtCore,QtWidgets import win32gui, win32api, win32con # 调用win32api的模拟点击功能实现ctrl+v粘贴 ...
随机推荐
- delphi nethttpclient操作cookie
delphi nethttpclient操作cookie unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysU ...
- Hive-概述
Hive:由 Facebook 开源用于解决海量结构化日志的数据统计. Hive 是基于 Hadoop 的一个数据仓库工具,可以将结构化的数据文件映射为一张表,并提供类 SQL 查询功能. 本质是:将 ...
- 2.4 Go语言基础之切片
本文主要介绍Go语言中切片(slice)及它的基本使用. 一.引子 因为数组的长度是固定的并且数组长度属于类型的一部分,所以数组有很多的局限性. 例如: func arraySum(x [3]int) ...
- 50行代码写的一个插件,破解一个H5小游戏
小游戏链接:测测你的眼睛对色差的辨识度http://www.webhek.com/post/color-test.html?from=timeline 废话不多说,先放代码: window.onloa ...
- SQL-W3School-高级:SQL CHECK 约束
ylbtech-SQL-W3School-高级:SQL CHECK 约束 1.返回顶部 1. SQL CHECK 约束 CHECK 约束用于限制列中的值的范围. 如果对单个列定义 CHECK 约束,那 ...
- 一百三十八:CMS系统之发布帖子前端js
先补一个功能,根据扥状态显示用户名/退出或者登录/注册 from .views import bpimport configfrom flask import session, gfrom .mode ...
- nginx虚拟机无法访问解决
.重要:修改配置文件使用虚拟机,否则怎么配置都不生效,添加如下用户 [root@host---- html]# ll /etc/nginx/nginx.conf -rw-r--r-- root roo ...
- swift 跳转到系统设置/网络/推送提醒
使用App-Prefs做域跳转,代码如下: if let url = URL(string: "App-Prefs:root=NOTIFICATIONS_ID"), UIAppli ...
- nginx 配置 https 并强制跳转(lnmp一键安装包)
目录 一.安装包 二.配置 三.查看配置文件 3.1.设定强制跳转 https 3.2 Rewrite 常用全局变量举例 一.安装包 安装大家按照官方说的安装即可. ./install.sh lnmp ...
- 用Python搞出自己的云词图 | 【带你装起来】
作者:AI算法与图像处理 参考:http://www.sohu.com/a/149657007_236714 云词图简介 什么词云 由词汇组成类似云的彩色图形.“词云”就是对网络文本中出现频率较高的“ ...