为什么 VScode ChromeDriver 不显示我尝试打开的网站网址?



我正在做一个抓取项目,最近下载了python(3.9.5(、VScode、Selenium和BeautifulSoup。所有模块似乎都正常工作,运行代码时我没有收到任何错误。然而,当我运行代码时,web驱动程序并没有打开URL——什么都没发生?请帮我找不到什么,这样我就可以看到我的控制窗口/显示屏了。

代码:

import csv
from bs4 import BeautifulSoup
from selenium import webdriver
# Startup the webdriver
driver = webdriver.Chrome()
url = 'https://www.amazon.com'
driver.get(url)

输出:

[Running] python -u "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/site-packages/
ScrapingTest.py"
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/element.py:16:
UserWarning: The soupsieve package is not installed. csS selectors cannot be used.
'The soupsieve package is not installed. CSS selectors cannot be used.'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ScrapingTest.py",
line 2, in <module>
from bs4 import BeautifulSoup
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/_init_-py",
line 32, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/builder/
_init_.py", line 7, in <module>
from bs4.element import (
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/element.py",
line 19, in <module>
from bs4. formatter import (
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/formatter.py",
line 1, in <module>
from bs4.dammit import EntitySubstitution
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/dammit.py",
line 68, in <module>
class EntitySubstitution(object):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/dammit.py",
line 97, in EntitySubstitution
CHARACTER_TO_HTML_ENTITY_RE) = _populate_class_variables ()
File "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/site-packages/bs4/dammit.py",
line 83, in _populate_class_variables
character = chr(codepoint)
ValueError: chr() arg not in range (256)
[Done] exited with code=1 in 0.198 seconds

错误消息指出:

UserWarning:未安装soupsieve软件包。不能使用css选择器。

因此,使用pip install soupsieve安装soupsieve包应该可以修复错误。

相关内容

  • 没有找到相关文章

最新更新