AndyReifman / ArseneWenger

1 stars 12 forks source link

Last 5 games function #8

Closed RrezonB closed 3 years ago

RrezonB commented 3 years ago

Creates a function that replies with last 5 games arsenal had with that club and the results.

Still need to add more clubs but if you give the ok for that i can add a bunch more

AndyReifman commented 3 years ago

This looks like an interesting feature however at this time it's not something I want to implement unless you can find a way to have it automatically generated/updated.

I don't want to have to make changes to the code every single time Arsenal play a match.

If you want to attempt that, I would look at using a site like 11v11 to scrape the data from. For example this is the Arsenal v Chelsea page. https://www.11v11.com/teams/arsenal/tab/opposingTeams/opposition/Chelsea/

RrezonB commented 3 years ago

from bs4 import BeautifulSoup

source = requests.get("https://www.11v11.com/teams/arsenal/tab/opposingTeams/opposition/Chelsea/")

soup = BeautifulSoup(source.text, 'lxml')
games = soup.find_all(class_="result-status")
chelsea = []

for game in games:
    chelsea.append(game.text)
last5 = chelsea[-5:]
print(last5)

This is the code for scraping through the site and saving it to a list. I'm not sure what to do next so if you have any ideas as to how to go forward i'm all ears