代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。