gpt4 book ai didi

python - "Permission Denied"错误废墟 Selenium 刮

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

我一直在使用 Selenium(Python Webdriver)抓取一个网站。当我尝试将它作为 click() 选项时,我收到了权限被拒绝的错误。完整堆栈跟踪:

Traceback (most recent call last):
File "scrape.py", line 19, in <module>
subjectOptions[1].click()
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 45, in click
self._execute(Command.CLICK_ELEMENT)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webelement.py", line 194, in _execute
return self._parent.execute(command, params)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 153, in execute
self.error_handler.check_response(response)
File "/Library/Python/2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 147, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u"'Error: Permission denied for <http://localhost/scrape_test> to get property HTMLDocument.compatMode' when calling method: [wdIMouse::move]"

这是导致问题的代码。我知道我尝试单击的选项存在(基于 print):

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait #available since 2.4.0
import time

# Create a new instance of the FireFox driver
driver = webdriver.Firefox()

# go to the local version of the page for testing
driver.get("http://localhost/scrape_test")

# Find the select by ID, get its options
selectElement = driver.find_element_by_id("CLASS_SRCH_WRK2_SUBJECT$65$")
subjectOptions = selectElement.find_elements_by_tag_name("option")

# Click the desired option
subjectOptions[1].click()

我在 Mac OS X 10.7.2 上使用 Firefox 8.0.1

最佳答案

看起来这是一个网络驱动程序错误。最新log entry来自上次修改其中一个 selenium 源代码文件的程序员说:

This leads to permissions errors, which I've still been unable to reduce:

Error: Permission denied for http://www.finn.no to get property HTMLDocument.compatMode' when calling method: [wdIMouse::move]

关于这个问题有一些讨论here , herehere .

根据讨论,它应该可以与 Firefox 7 一起正常工作。另外,this related issue意味着尽管有错误,链接仍然被点击,所以它可能在 try/except 中工作。

关于python - "Permission Denied"错误废墟 Selenium 刮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8581151/

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