Created
May 31, 2024 14:52
-
-
Save sadkris/acca91b7692f4e6d168c5edde719811a to your computer and use it in GitHub Desktop.
Every PC Game without "A" in its title
This file contains hidden or 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 pandas as pd | |
| import requests | |
| import warnings | |
| warnings.simplefilter(action='ignore', category=FutureWarning) | |
| pageRoot = "https://en.wikipedia.org/wiki/" | |
| gameLists = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Numerical"] | |
| validGames = [] | |
| def getGameList(letter): | |
| html = requests.get(pageRoot+f"List_of_PC_games_({letter})").text | |
| df = pd.read_html(html)[0] | |
| try: | |
| gameList = df["Name"].tolist() | |
| except: | |
| gameList = df["Title"].tolist() | |
| return gameList | |
| def filterGames(): | |
| for letter in gameLists: | |
| letterGames = getGameList(letter) | |
| for game in letterGames: | |
| if not "A" in game.upper(): | |
| validGames.append(game) | |
| return validGames | |
| if __name__ == "__main__": | |
| print(filterGames()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment