我正在从这个网站上抓取一些信息:https://www.adamchoi.co.uk/teamgoals/detailed 但是,当我try 获取我的.csv文件时,我得到一个空的DataFrame.因此,我决定测试for循环并打印.当我经营它的时候,我得不到任何回报.我不明白哪里出了问题
以下是我的代码:
from selenium import webdriver
from selenium.webdriver.support.ui import Select
import pandas as pd
import time
website = 'https://www.adamchoi.co.uk/teamgoals/detailed'
path = r'C:/Users/Ronald C/Downloads/Data Analyst Portfolio Porjects/Project 5 Web Scrapping/chromedriver.exe'
driver = webdriver.Chrome(path)
driver.get(website)
all_matches_button = driver.find_element_by_xpath('//label[@analytics-event="All matches"]')
all_matches_button.click()
drop_country = Select(driver.find_element_by_id('country'))
drop_country.select_by_visible_text('Spain')
time.sleep(5)
drop_season = Select(driver.find_element_by_id('season'))
drop_season.select_by_visible_text('21/22')
# Creating a list with all the matches
matches = driver.find_elements_by_tag_name('tr')
# Extraction of the list "matches"
# match_list = []
# for match in matches:
# match_list.append(match.text)
# driver.quit()
for match in matches:
print(match.text)