From c01abc2213051320589c552d411c7fef4971d85e Mon Sep 17 00:00:00 2001 From: SecretlyTaco Date: Sun, 11 Sep 2016 20:22:48 +0100 Subject: [PATCH] Can get top 5 teams and match list --- main.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..002ad44 --- /dev/null +++ b/main.py @@ -0,0 +1,37 @@ +import requests +import json +from bs4 import BeautifulSoup + +home = requests.get("http://hltv.org/").text +home = BeautifulSoup(home, "lxml") + +matches = requests.get("http://www.hltv.org/matches/").text +matches = BeautifulSoup(matches, "lxml") + + +def top5teams(): + count = 0 + teams = [] + for team in home.find_all("div", {"class": "vsbox",})[:5]: + count += 1 + teamname = team.find_all("div")[2].text.strip() + teams.append(teamname) + return teams + +def getmatches(): + match_data = [] + matchlist = matches.find_all("div", {"class": ["matchListBox", "matchListDateBox"]}) + for match in matchlist: + if match['class'][0] == "matchListDateBox": + print "*", match.text + else: + try: + time = match.find("div", {"class": "matchTimeCell"}).text.strip() + team1 = match.find("div", {"class": "matchTeam1Cell"}).text.strip() + team2 = match.find("div", {"class": "matchTeam2Cell"}).text.strip() + print(time + " " + team1 + " vs " + team2) + except: + print match.text[:7].strip(), match.text[7:-7].strip() + +if __name__ == "__main__": + getmatches()