#!/usr/bin/python
# -*- coding: UTF-8 -*-
# @Time : 2019/12/5 17:30
# @Author : shenghao/10347899@qq.com
'''test with selenium's move'''
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.save_img(rid)
except:
pass def save_img(self,rid):
'''//div[@class = 'dvc-slider__handler'] button position'''
image_name = datetime.datetime.now().timestamp()
element = self.driver.find_element_by_xpath("//img[@class='dvc-captcha__bgImg']").screenshot_as_png
with open(r'./%s_%s.png' % (rid,image_name), 'wb') as f:
f.write(element)
print(">>>>>>>>>>>>>>>>>>>>>> %s" % element)
time.sleep(2)
self.driver.close() if __name__ == '__main__':
h = selenium()
h.visit_index()

最新文章

  1. 关系数据库常用SQL语句语法大全
  2. GIT使用笔记-fatal:multiple stage entries for merged file处理办法
  3. IntelliJ IDEA - 代码辅助功能
  4. windows命令行(Command Prompt / Console)字体设置
  5. PHP写一段代码,确保多个进程同时写入一个文件成功
  6. poj 2348
  7. ruby函数回调的实现方法
  8. RabbitMQ+PHP 消息队列环境配置
  9. ecexl操作
  10. python hmac-sha1
  11. 阿里云ubuntu安装jdk8+mysql+tomcat
  12. 贪心算法----区间选点问题(POJ1201)
  13. spring boot拦截器中获取request post请求中的参数(转)
  14. Laravel5.5+ 区分前后端用户登录
  15. Nginx代理MysqlCluster集群(二)
  16. mysql批量更新的两种方式效率试验<二>
  17. Software Testing 3
  18. delphi Drag and Drop sample 鼠标拖放操作实例
  19. Django Model基础 ORM
  20. ruby中的**

热门文章

  1. 安装RabbitMQ管理插件失败
  2. 如何修改layer-layui中的confirm
  3. exactly the kind of division of tasks that Gulp.js is built on
  4. 阶段5 3.微服务项目【学成在线】_day03 CMS页面管理开发_14-异常处理-异常处理的问题分析
  5. 阶段5 3.微服务项目【学成在线】_day02 CMS前端开发_07-vuejs研究-vuejs基础-v-bind指令
  6. java引用如果是成员变量则引用本身不保存在栈上的汇编级调试证明
  7. JAVA 基础编程练习题31 【程序 31 数组逆序】
  8. 去除表视图section的粘性问题
  9. sed例子
  10. ubuntu 16 搭建只能上传不可下载删除ftp服务