English 中文(简体)
Chromedriver 无法生成网络切除数据
原标题:chromedriver not render the web scrapping data

我正试图用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" > 问题图像

最佳回答

您需要从 < a href=" https://googlechromelabs.github.io/chrome- for- controduction/" rel=“ nofollow noreferrer" > Chrome for test page下载铬和铬。

而不是 webdriver.Chrome () , 使用以下代码 :

from selenium.webdriver.chrome.service import Service

service = Service(chrome_driver_path)
options = webdriver.ChromeOptions()
options.binary_location = chrome_binary_path
driver = webdriver.Chrome(service=service, options=options)

下载相同版本的铬和铬, 并在脚本中添加它们的路径 。

问题回答

同一问题在此在此解决, 问题: < a href="https://stackoverflow.com/ questions/42478591/ python- serium- chrome-webdriver" > Python Siteum Chrome Webdriver

如果你的问题还没解决 请对我的答复发表评论...





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签