【发布时间】:2021-05-20 07:44:20
【问题描述】:
我要刮这个页面https://www.sofascore.com/betting-tips-today 我用 selenium 创建了代码但不起作用:
from bs4 import BeautifulSoup
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(executable_path=r"C:/chromedriver.exe") #, options=options)
url = "https://www.sofascore.com/betting-tips-today"
driver.get(url)
WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.CSS_SELECTOR,'.fsFjfS'))) #wait until the element be present
time.sleep(5)
soup = BeautifulSoup(driver.page_source, 'html.parser')
它返回这个错误:
raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message:
我尝试了没有等待但没有返回任何东西。
【问题讨论】:
-
你想拉什么?有一个 api,所以你可能不需要 selenium,
标签: python selenium-webdriver web-scraping