This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for tag in tags: | |
match_dictionary = {} | |
date = tag.find("span", {"class": "bday dtstart published updated"}) | |
print(date.get_text()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for tag in tags: | |
match_dictionary = {} | |
date = tag.find("span",{"class":"bday dtstart published updated"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for tag in tags: | |
match_dictionary = {} | |
date = tag.find("span", {"class": "bday dtstart published updated"}) | |
match_dictionary["Date"] = date.get_text() | |
time = table.find("div", {"class": "ftime"}) | |
match_dictionary["Time"] = time.get_text() | |
home_team = table.find("th", {"itemprop": "homeTeam"}) | |
away_team = table.find("th", {"itemprop": "awayTeam"}) | |
match_dictionary["Match"] = home_team.get_text() + " vs " + away_team.get_text() | |
matches.append(match_dictionary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for match in matches: | |
print(match) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip3 install requests, xlsxwriter, bs4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import xlsxwriter | |
from bs4 import BeautifulSoup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import xlsxwriter | |
from bs4 import BeautifulSoup | |
# Captures Wikipedia article response. | |
webpage = requests.get("https://en.wikipedia.org/wiki/2022_FIFA_World_Cup") | |
# Parses Wikipedia article HTML. | |
soup = BeautifulSoup(webpage.text, "html.parser") | |
tags = soup.find_all("div", {"class": "footballbox"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for index, column in enumerate(COLUMN_NAMES): | |
worksheet.write(0, index , column) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
row_index = 1 | |
column_index = 0 | |
for match in matches: | |
for value in match.values(): | |
worksheet.write(row_index, column_index, value) | |
column_index += 1 | |
row_index += 1 | |
column_index = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import xlsxwriter | |
COLUMN_NAMES = ["Date", "Time", "Match"] | |
# Captures Wikipedia article content. | |
content = requests.get("https://en.wikipedia.org/wiki/2022_FIFA_World_Cup") | |
# Parses Wikipedia article HTML. |
OlderNewer