我已经try 过多次使用教程中的其他指令代码,这些代码都很好.然而,当我刚刚更改了URL和下面的类时,它会给出一个错误:
selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: An invalid or illegal selector was specified
(Session info: chrome=100.0.4896.88)
当我使用教程代码时,一切都正常.
这是我的代码(我已经从互联网上解决了一些chrome驱动程序问题)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-logging"])
driver = webdriver.Chrome(options=options)
driver.get("https://raritysniper.com/nft-drops-calendar")
time.sleep(1)
link = driver.find_element_by_css_selector(".w-full.h-full.align-middle.object-cover.dark:brightness-80.dark:contrast-103.svelte-f3nlpp").get_attribute("alt")
print(link)
我正在try 获取每个项目的属性,并将它们转换为csv.
Screen shot of HTML that I am trying to extract
如果有人能描述我在代码上遇到的问题,那就太好了.
非常感谢.