def __init__(self, port, ip): self.temp_filename = get_filename('.txt', 'template') self.temp_dict = get_temp_dict(self.temp_filename) # 模板 self.ip = ip #kill_pid(port) kill_all_chorme() sleep(3) # 关闭进程 self.cmd = r'"{chrome_path}" --remote-debugging-port={port} --user-data-dir="C:\selenum\AutomationProfile{port}" --window-size=1080,800 '.format( chrome_path=chrome_path, port=port) # --headless #加代理ip,#标记要修改 # self.cmd = r'"{chrome_path}" --remote-debugging-port={port} --user-data-dir="C:\selenum\AutomationProfile{port}" --window-size=1080,800 --proxy-server=http://{ip}'.format( # chrome_path=chrome_path, port=port, ip=ip) # --headless os.popen(self.cmd) chrome_options = Options() chrome_options.add_experimental_option( "debuggerAddress", "127.0.0.1:{port}".format(port=port)) self.driver = webdriver.Chrome(executable_path="./chromedriver.exe", options=chrome_options) script = ''' Object.defineProperty(navigator, 'webdriver', { get: () => undefined }) ''' set_driver(self.driver) self.driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": script}) Config.implicit_wait_secs = 10 #设置隐式等待时间15秒 self.ip_state = 1 #self.chick_ip() #标记要修改
def liucheng4(): """ 图片6,6-2,7 ,8填写生日 SSN , 和确认提交 :return: """ global personal_information_filename global personal_information_dict global phone_filename global phone_dict global email_filename global email_dict global firse_name global last_name global email print('开始图片第6,6-2,7,8张流程,填写生日 SSN信息等') birth_date = personal_information_dict.get('生日') # 1985/5/19 birth_date = birth_date.split('/') if len(birth_date[1]) == 1: birth_date[1] = '0' + birth_date[1] str2 = birth_date[1] + '/' + birth_date[2] + '/' + birth_date[0] write(str2, into=S('//*[@id="formRegister:dob"]')) # 生日 save_txt('生日:{}'.format(str2)) SSN = personal_information_dict.get('SSN') # 1985/5/19 write(SSN, into=S('//*[@id="formRegister:UIClaimant_social"]')) # SSN save_txt('SSN:{}'.format(SSN)) click(S('//*[@id="formRegister:buttondoAddReg"]')) # 确认 try: wait_until( Text('The SSN you provided is already in our records').exists, timeout_secs=5, interval_secs=0.4) print('SSN已被注册,跳过此行数据,从头开始注册') del_line(personal_information_dict.get('驾照号'), personal_information_filename) # 删除个人信息 sleep(0.15) personal_information_filename = get_filename('.txt', '个人信息') personal_information_dict = get_temp_dict( personal_information_filename) # 个人信息 phone_filename = get_filename('.txt', '个人电话') phone_dict = get_phone_dict(phone_filename) # 个人电话 email_filename = get_filename('.txt', '个人邮箱') email_dict = get_email_dict(email_filename) # 邮箱 firse_name = personal_information_dict.get('First 名字') last_name = personal_information_dict.get('last 姓') email = email_dict.get('邮箱地址') zhuce() except: pass
from email_oper import * from get_template import get_temp_dict from send_request import SendRequest from selenium.webdriver.support.ui import Select from yanzhengqi_oper import get_make_code from base64_to_img import to_png from chick_proxy import servers_chick_ip from del_txt_line import del_line #用一行删除一行 from url_2_png import get_src_img import datetime """ 滑动图片验证 """ from get_template import get_temp_dict, get_filename temp_filename = get_filename('.txt', 'template') temp_dict = get_temp_dict(temp_filename) # 模板 def get_file_code(filename): f3 = open(filename, 'rb') data = f3.read() encode = chardet.detect(data).get('encoding') f3.close() return encode #path1 = os.path.dirname(os.path.abspath(__file__)) # 获取当前目录 path2 = 'config.ini' encode = get_file_code(path2) config = configparser.RawConfigParser() config.read(path2, encoding=encode)
# write('854639',into=S('//*[@name="verifyOTPButton"]')) # write('+86 18040377309',into=S('//*[@id="country-phone-input"]')) # click(S('//*[@id="go"]')) print(driver.title) # def check_img_exist( img_name): # driver.save_screenshot('./img/screen_all.png') # sleep(0.2) # try: # x, y = PictureRecognition.matchImg(img_name, './img/screen_all.png') # return True # except: # return False # personal_information_filename = get_filename('.txt', '个人信息') personal_information_dict = get_temp_dict( personal_information_filename) # 个人信息 phone_filename = get_filename('.txt', '个人电话') phone_dict = get_phone_dict(phone_filename) # 个人电话 email_filename = get_filename('.txt', '个人邮箱') email_dict = get_email_dict(email_filename) # 邮箱 firse_name = personal_information_dict.get('First 名字') last_name = personal_information_dict.get('last 姓') email = email_dict.get('邮箱地址') # print("生成随机用户名:",username) # pwd = get_ranrom_str(16) # print("生成随机密码:",username) # write(username, into=S('//*[@id="userID"]')) # 用户名 # write(pwd, into=S('//*[@id="userPassword"]')) # 密码 # write(pwd, into=S('//*[@id="userPassword2"]')) # 确认密码 # # write('123', into=S('//*[@id="userEmailConfirm"] ')) # Confirm E-mail Address