【发布时间】:2021-11-22 04:32:06
【问题描述】:
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
options = Options()
options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'
driver = webdriver.Firefox(executable_path=r'C:\Users\******\Downloads\geckodriver.exe', options=options)
#driver.get('http://google.com/')
url = "https://www.foxnews.com/sports/nfl-great-frank-gore-says-hall-of-famer-numbers-speak-themselves"
driver.get(url)
item = driver.execute_script("return document.querySelector('div.article-comments').shadowRoot.querySelector('ul.spcv_messages-list')")
print(item.text)
driver.maximize_window()
driver.get(url)
注意:我正在尝试抓取福克斯新闻 cmets:https://www.foxnews.com/sports/nfl-great-frank-gore-says-hall-of-famer-numbers-speak-themselves。请帮我解决这个问题
【问题讨论】:
标签: python-3.x selenium-webdriver beautifulsoup