当浏览器打开时,它只是停留在原地不动,不起作用.driver.get(url)
不会发出请求,浏览器中什么都不会发生.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service as ChromeService
import time
chrome_executable_path = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
# path to the chrome profile to get the logged google acc
chrome_profile_dir = r"C:\Users\myuser\AppData\Local\Google\Chrome\User Data\Profile 3"
# use the chrome profile
chrome_options = Options()
chrome_options.add_argument(f"user-data-dir={chrome_profile_dir}")
service = ChromeService(executable_path=chrome_executable_path)
driver = webdriver.Chrome(service=service, options=chrome_options)
# this doesn't work, but it's not related to the url/nothing after this
url = "https://docs.google.com/forms/d/e/myformid/viewform?usp=pp_url&entry.1824=abc&entry.20988=def&entry.1589=123"
driver.get(url)
time.sleep(10)
submit_button = driver.findElement(By.xpath("//span[text()='Enviar']"))
submit_button.click()
# wait for form submission
time.sleep(10)
driver.quit()
我相信这和 chromium 合金emits 器有关.我必须使用完整的Chrome实例,因为我需要共享Google会话才能使用我的Google帐户发送Google表单.
我try 的是提交一份预填好的谷歌表格.我不知道如何让我的当前会话向/formResponse发出POST请求,所以我想我应该直接使用已经登录的实例.