gpt4 book ai didi

python - Selenium WebDriverException 中的空错误消息

转载 作者:太空宇宙 更新时间:2023-11-04 06:14:32 26 4
gpt4 key购买 nike

我正在尝试使用 Selenium/BeautifulSoup 对网页进行单元测试。尽管我无法使用 Google,但我收到了一个错误。

selenium.common.exceptions.WebDriverException: 消息: ''

我正在使用 Firefox 的可移植版本和代理。

import urllib2
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import time
import sys

def getItemDivs(url):
profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override","Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/21.0")
profile.set_preference("network.proxy.http", "proxy.example.com")

ffbin = webdriver.firefox.firefox_binary.FirefoxBinary('C:\\FirefoxPortable\\App\\Firefox\\firefox.exe')

# IT FAILS ON THE NEXT LINE
driver=webdriver.Firefox(profile, firefox_binary=ffbin)
driver.implicitly_wait(30)

# THIS LINE CONTAINS A VALID COOKIE, BUT IT HAS BEEN REMOVED FOR THIS QUESTION.
driver.add_cookie(<<mycookie>>)
base_url = url
verificationErrors = []
accept_next_alert = True

driver.get(base_url)
scrap1 = driver.page_source
soup = BeautifulSoup(scrap1)

这个问题类似于this one但是,在那个问题中,他们有一个成功的第一个请求。我还没有成功。

什么会导致这种类型的异常但将消息留空?

最佳答案

问题是我没有设置network.proxy.port。添加此行解决了问题:

profile.set_preference("network.proxy.port", "80")

关于python - Selenium WebDriverException 中的空错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16593587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com