-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_.py
70 lines (53 loc) · 1.8 KB
/
main_.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import requests
from bs4 import BeautifulSoup
def get_page(url):
response = requests.get(url)
soup = BeautifulSoup(response.content)
return soup
# response.status_code
def get_leagues(soup):
lst=list()
leagues = soup.find('div', class_="league-side")
for a in leagues.find_all('a', href=True):
url= a['href']
team_name=a.text.strip()
tmp={
'team_name':team_name,
'url':url,
}
lst.append(tmp)
return lst
def matches_time(soup):
lst=list()
result = soup.find(id="matchTable")
mats = result.find_all('div', class_"match-event")
# item=mats[0]
for item in mats:
firstTeam = item.find('div', class_="first-team").find('div',
class_="team-name team-name-ar").find('span').text
secondTeam = item.find('div', class_="left-team").find('div',
class_="team-name team-name-ar").find('span').text
time = item.find(id="result-now").text
tmp={
'firstTeam':firstTeam,
'secondTeam':secondTeam,
'time':time
}
# print(firstTeam, " vs ", secondTeam, " time ", time)
lst.append(tmp)
return lst
def standings_of_league(link):
lst=[]
soup = get_page( link)
standing = soup.find(id='standings').find_all('div', class_="row-standing")
for row in standing:
team_name=row.find('div', class_="standing-team").text.strip()
points=row.find('div', class_="standing-pt").text.strip()
num_wins=row.find('div', class_="standing-win").text.strip()
tmp={
"team_name":team_name,
"points":points,
"num_wins":num_wins
}
lst.append(tmp)
return lst