前面我们说过了数字英文的验证码识别操作,本章我们对其进行完善一下,结合selenium来实际操作操作。
import os
import time
def coding_path(path):
Base_Path = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + '/..')
Base_image = os.path.join(Base_Path + r'\PIC', path)
return Base_image
def time_():
# %Y_%m_%d_%H_%M_%S
file_name = time.strftime("%Y_%m_%d_%H_%M") + ".png"
return file_name
首先先来写一个时间戳,你没看错,我想用时间戳来保存截图。至于coding_path就是一个相对路径,读取文件位置的一个函数。里面Base_Path是获取相对路径,Base_image是用的路径拼接的方式存放截图图片的。
接下来就是正文了
class Brouse:
def __init__(self):
self.fox = webdriver.Firefox()
def save_image(self):
"""
截图
:return:
"&