我正试图用Python来收集网站数据
I am using selenium version 4.20.0 I haven t installed chromedriver in my system. however my script was running just fine using just chrome.
91 更新后, 当我运行脚本时, 我的铬还在工作, 但它只是没有提供任何数据。
只显示“ 数据; ”, 继续显示在标签和 URL 搜索输入框上 。
下面是我的代码和截图 数据无法传输的截图。
import configparser
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException
from openpyxl import load_workbook
import time
import os
import logging
# Get the download path for the current user
config = configparser.ConfigParser()
# Configure logging
logging.basicConfig(filename= app.log , level=logging.INFO, format= %(asctime)s - %(levelname)s - %(message)s )
def run_script(config):
config.read( credentials.ini )
# Load the workbook
book = config [ Credentials ][ saveFilePath ]
wb = load_workbook(book)
ws = wb.active
# Clear the sheet
ws.delete_rows(2, ws.max_row)
# Find the next empty row in the worksheet
next_row = ws.max_row + 1
username = config[ Credentials ][ username ]
password = config[ Credentials ][ password ]
AgencyFilePath = config[ Credentials ][ AgencyFilePath ]
workbook = load_workbook(AgencyFilePath)
sheet = workbook.active
try:
driver = webdriver.Chrome()
login_url = https://www.google.com
driver.get(login_url)
wait = WebDriverWait(driver, 30)
username_field = wait.until(
EC.element_to_be_clickable((By.XPATH, //*[@id="lock-title"] ))
)
# Find the username and password input fields and submit button by class name
username_field = driver.find_element(
By.XPATH, //*[@id="1-email"] #xpath of username field
).send_keys(username)
password_field = driver.find_element(
By.XPATH, //*[@id="1-password"] #Xpath of password field
).send_keys(password)
< a href=> "https://i.sstatic.net/mLJ4OOOOOD.png" rel=“没有跟随 nofollow noreferrer" > 问题图像