1 Star 0 Fork 0

fjcyit/seleniumProject

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
AutoRegistController.py 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
fjcyit 提交于 2024-03-07 04:07 . Init
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from bit_api import *
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
class AutoRegister:
def init_seleconnect(id, df):
# print(data.iat[1,10])
res = openBrowser(id)
driverPath = res['data']['driver']
debuggerAddress = res['data']['http']
print(driverPath)
print(debuggerAddress)
# selenium 连接代码
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("debuggerAddress", debuggerAddress)
chrome_service = Service(driverPath)
driver = webdriver.Chrome(service=chrome_service, options=chrome_options)
# driver.get('https://www.baidu.com/')
driver.get('https://www.vinted.com/')
driver.find_element(By.XPATH, '//*[@id="__next"]/div/div/div[1]/header/div/div/div[3]/div/a[1]').click()
# driver.find_element(By.XPATH,'/html/body/div[44]/div/div/div/div[2]/div/span[1]/span').click()
driver.find_element(By.CSS_SELECTOR, '[data-testid="auth-select-type--register-email"]').click()
# print(driver.page_source)
# realName_input = driver.find_element(By.CSS_SELECTOR,'[name="realName"]')
# driver.execute_script('arguments!l.value ="Derek"', realName_input)
time.sleep(1)
for index, row in df.iterrows():
print('Index: ', index)
print('Name: ', row['realName'])
js = f'document.getElementById("realName").value="'+row['realName']+'"'
driver.execute_script(js)
js = f'document.getElementById("login").value="'+row['username']+'"'
driver.execute_script(js)
js = f'document.getElementById("email").value="'+row['email']+'"'
driver.execute_script(js)
js = f'document.getElementById("password").value="'+row['password']+'"'
driver.execute_script(js)
# subscribeToNewsletter
js = f'document.getElementById("subscribeToNewsletter").checked="true"'
driver.execute_script(js)
js = f'document.getElementById("agreeRules").checked="true"'
driver.execute_script(js)
print(driver.title)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fjcyit/selenium-project.git
git@gitee.com:fjcyit/selenium-project.git
fjcyit
selenium-project
seleniumProject
master

搜索帮助