python selenium3 模拟点击+拖动+保存验证码 测试对象 58同城验证码
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# @Time : 2019/12/5 17:30
# @Author : shenghao/10347899@qq.com
'''test with selenium's move'''
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
import matplotlib.pyplot as plt
import numpy as np class selenium_2_move(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()
time.sleep(1)
self.save_img()
except:
pass def save_img(self):
'''//div[@class = 'dvc-slider__handler'] button position'''
image_name = datetime.datetime.now().timestamp()
# self.driver.save_screenshot("%s.png" % image_name)
# print(image_name)
element = self.driver.find_element_by_xpath("//img[@class='dvc-captcha__bgImg']").screenshot_as_png
with open(r'./%s.png' % image_name, 'wb') as f:
f.write(element)
print(">>>>>>>>>>>>>>>>>>>>>> %s" % element)
time.sleep(2)
self.driver.close() if __name__ == '__main__':
h = selenium_2_move()
h.visit_index()
python selenium3 模拟点击+拖动+保存验证码 测试对象 58同城验证码的更多相关文章
- python selenium4 模拟点击+拖动+保存验证码 测试对象+以验证码的返回ID保存命名 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 selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码
#!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019年12月9日11:41:08 # @Author : shenghao/10347899 ...
- 如何使用python来模拟鼠标点击(将通过实例自动化模拟在360浏览器中自动搜索"python")
一.准备工作: 安装pywin32,后面开发需要pywin32的支持,否则无法完成与windows层面相关的操作. pywin32的具体安装及注意事项: 1.整体开发环境: 基于windows7操作系 ...
- Python使用selenium模拟点击(一)
本文适合有点Python基础阅读,(没基础的话,相对的比较蒙蔽,争取能让小白能一步一步跟上来) 2019-03-05 14:53:05 前几天由于需要到一个网站进行签到~~听说Python能够模拟请求 ...
- python 模拟点击微信
from PyQt5 import QtCore,QtWidgets import win32gui, win32api, win32con # 调用win32api的模拟点击功能实现ctrl+v粘贴 ...
- 七、Selenium与phantomJS----------动态页面模拟点击、网站模拟登录
每天一个小实例1(动态页面模拟点击,并爬取你想搜索的职位信息) from selenium import webdriver from bs4 import BeautifulSoup # 调用环境变 ...
- 【小白学爬虫连载(10)】–如何用Python实现模拟登陆网站
Python如何实现模拟登陆爬取Python实现模拟登陆的方式简单来说有三种:一.采用post请求提交表单的方式实现.二.利用浏览器登陆网站记录登陆成功后的cookies,采用get的请求方式,传入c ...
随机推荐
- dubbo 初识(1)
参考dubbo 中文官方文档:http://dubbo.apache.org/zh-cn/docs/user/preface/architecture.html 分布式架构的发展过程 1.初始小型的项 ...
- 使用Vagrant配置本地开发环境
从二零一四年开始使用vagrant+VirtualBox搭建linux开发环境,配置简单灵活,后台运行占用内存少,比vmware好用很多,果断弃用vmware转投vagrant的怀抱:无论是个人搭建开 ...
- Java同步数据结构之SynchronousQueue
前言 严格来说SynchronousQueue并不是像它的名字那样是一种Queue,它更像是一个数据接力的交汇点,还记得在介绍Exchanger的时候提到过Exchanger可以看作是Synchron ...
- js常用时间转换函数
1.秒转换为时分秒 // 秒转换为时分秒 export function secExchangeMoment(value = 0){ let secondTime = parseInt(value); ...
- centos7.4出现yum command not found
购买的云服务器运行yum命令出现yum command not found. 通过将云主机自带的yum和python卸载掉,并且同时需要关注/usr/bin/yum文件的首行解释.我定义其为" ...
- 09 Flutter底部Tab切换保持页面状态的几种方法
IndexedStack:保此所有页面的状态: AutomaticKeepAliveClientMixin:保此部分页面的状态: 修改的页面代码: 页面效果: Tabs.dart import 'pa ...
- IDEA配置SpringBoot应用的profile启动参数
参考博客:https://blog.csdn.net/li396864285/article/details/83576829 如图为, 配置多台eureka的启动参数, 分别为: --spring. ...
- [MSCOCO] Ubuntu16.04下使用 tylin/coco-caption 评价 MSCOCO Caption(配置,及Demo运行)
Github链接:https://github.com/tylin/coco-caption Ubuntu版本信息 Linux内核版本号:Linux version 4.15.0-51-generic ...
- switch/catch
public class SwitchTest { public static void main(String[] args) { String param = null; switch (para ...
- Vulnhub-XXE靶机学习
------------恢复内容开始------------ 前两天在微信公众号上看见了这个XXE靶场,就想试一试,虽然网上关于这个的文章已经写了太多太多了,但还是要写出来划划水,233333333, ...