本文主要是解决验证码截图偏移问题
如下便是我编写的关于识别网址验证码的位置的代码
#coding:utf-8
from selenium import webdriver
import random
import tesserocr
import re
import requests
import pytesseract
from selenium import webdriver
from PIL import Image, ImageEnhance,ImageGrab
import os
import time
from pytesser3 import *
def loginWeb(urlAddr):
#模拟验证码
'''
#chrome驱动
chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" # 这里写本地的chromedriver 的所在路径
os.environ["webdriver.Chrome.driver"] = chromedriver # 调用chrome浏览器
options = webdriver.ChromeOptions()
options.add_argument(
'user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"')
driver = webdriver.Chrome(chromedriver, chrome_options=options)
'''
#firefox驱动
options = webdriver.FirefoxOptions()
options.add_argument(
'user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36"')
driver = webdriver.Firefox(firefox_options=options,executable_path='./geckodriver.exe')
driver.get(urlAddr) # 该处为具体网址
driver.refresh() # 刷新页面
#driver.maximize_window() # 浏览器最大化
driver.set_window_size(1280, 1024)
width_driver = driver.get_window_size()['width']
# 获取全屏图片&