AndyReifman / ArseneWenger

1 stars 12 forks source link

THIS IS THE UPDATED BOT WITH AUTOMATIC CHANGE #10

Closed RrezonB closed 3 years ago

RrezonB commented 3 years ago

This is the fully functional bot that replies with the last 5 games. The output is a bit ugly but you can change that to match the wengerbot style by changing the source code. I added some comments in the code to explain it!

AndyReifman commented 3 years ago

This is good progress.

I would look in to generating the last 5 matches on the fly dynamically for each team

For example, create a method that will gather the last five results against team X, and then you can pass team name X to that method.

Additionally, please make sure this is an actual python file with an appropriate file name.

RrezonB commented 3 years ago

Will try and do this. Thanks for the input!

RrezonB commented 3 years ago

from bs4 import BeautifulSoup
class gamecheck:
    def __init__(self, name):
        if name == "leicester":
            source = requests.get("https://www.11v11.com/teams/arsenal/tab/opposingTeams/opposition/Leicester%20City/")
        elif name == "manutd":
            source = requests.get("https://www.11v11.com/teams/arsenal/tab/opposingTeams/opposition/Manchester%20United/")

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

        for game in games:
            allgames.append(game.text)
        last5 = allgames[-5:]
        print(last5)
u = gamecheck("manutd")
d = gamecheck("leicester")

Is this sufficent?