-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscrapLDC.py
64 lines (49 loc) · 1.87 KB
/
scrapLDC.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
from bs4 import BeautifulSoup
import requests, sys, getopt
##############################
# Récupération des arguments #
##############################
email = ''
password = ''
# Insérez ci-dessous le nom de votre équipe
team_name="Brazilala"
sys.argv.remove(sys.argv[0])
try:
opts, args = getopt.getopt(sys.argv, 'he:p:d:')
except getopt.GetoptError:
print('scrapLDC.py -e <email> -p <password>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('scrapLDC.py -e <email> -p <password>')
sys.exit()
elif opt == '-e':
email = arg
elif opt == '-p':
password = arg
def main(_email, _password,_team_name):
retour = ""
####################
# Authentification #
####################
session = requests.Session()
payload = {'email': _email, 'password': _password, 'remember': 'on'}
URLconnection = 'http://fantasy.sofoot.com/login.php'
session.post(URLconnection, data=payload)
#########################################
# Récupération des compétitions du jour #
#########################################
URLEuropa = 'http://fantasy.sofoot.com/?tpl=group-champion'
ajaxMatches = session.get(URLEuropa)
soup = BeautifulSoup(ajaxMatches.content, "lxml")
matches_coupe = soup.find_all(class_="tournament-bracket__match")
for match in matches_coupe:
equipes_match = match.find_all("abbr")
if team_name == equipes_match[0].contents[0].strip() or team_name == equipes_match[1].contents[0].strip():
score_match = match.find_all(class_="tournament-bracket__number")
retour = equipes_match[0].contents[0].strip() + "," + score_match[0].string + '\n' \
+ equipes_match[1].contents[0].strip() + "," + score_match[1].string
print(retour)
return retour
if __name__ == '__main__':
main(email, password, team_name)