Форум сайта python.su
Добрый вечер! Помогите спарсить данные ( Phyton) с данного сайта Whoscored нужно всего два столбца игрок и рейтинг. Подскажите пожалуйста ?
Офлайн
https://beautiful-soup-4.readthedocs.io/en/latest/#
ps удали дубликат темы
Отредактировано AD0DE412 (Дек. 26, 2022 00:06:51)
Офлайн
from selenium import webdriver from selenium.webdriver.gekodriver.service import Service from webdriver_manager.geko import GekoDriverManager from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import pandas as pd url = 'https://www.whoscored.com/Matches/1549539/LiveStatistics/England-Premier-League-2021-2022-Brentford-Arsenal' s = Service(GekoDriverManager().install()) driver = webdriver.Geko(service=s) # web driver goes to page driver.get(url) WebDriverWait(driver, 15).until( EC.presence_of_element_located((By.ID, 'player-table-statistics-body')) ) Players_list = [] Player_rating = [] for nme in driver.find_elements(By.CSS_SELECTOR, 'a.player-link span.iconize.iconize-icon-left'): Players_list.append(nme.text) for rat in driver.find_elements(By.CSS_SELECTOR, 'td.rating'): Player_rating.append(rat.text) data = {'name': Players_list, 'rating': Player_rating} df = pd.DataFrame(data) print(df) df.to_csv('brentford-arsenal.csv')
Офлайн