簡體   English   中英

Python /精美湯-find_all限制結果

[英]Python/Beautiful Soup - find_all limit limits results

我正在嘗試從英超聯賽中獲得歷史結果,但是當html獲取所有結果時,Beautiful Soup find_all僅返回200個結果(應該有463個結果。總有辦法解決這個問題嗎?

非常感謝

馬特

import requests
from bs4 import BeautifulSoup
url = "https://www.skysports.com/premier-league- 
results/1992-93"
url_content = requests.get(url).content
url_bs = BeautifulSoup(url_content,'html.parser')
match_list = 
url_bs.find_all(attrs="class":"fixres__item"})
print(len(match_list))
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(options=options)
driver.get('https://www.skysports.com/premier-league-results/1992-93')
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CLASS_NAME, 'plus-more__text')))

if driver.find_element_by_class_name('plus-more__text'):
    print('Found')
    driver.execute_script("arguments[0].scrollIntoView();", driver.find_element_by_class_name('plus-more__text'))
    driver.execute_script("arguments[0].click();", driver.find_element_by_class_name('plus-more__text'))

html = driver.page_source
soup = BeautifulSoup(html, 'lxml')

links = soup.findAll('div', class_='fixres__item')

print(len(links))


driver.quit()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM