Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import gspread
  2. from oauth2client.service_account import ServiceAccountCredentials
  3. import datetime
  4. import pymysql.cursors
  5. import requests
  6. import pprint
  7. import math
  8. import datetime
  9.  
  10.  
  11. connection = pymysql.connect(host='localhost',
  12. user='admin',
  13. password='admin',
  14. db='pariuri',
  15. autocommit=True,
  16. charset='utf8mb4',
  17. cursorclass=pymysql.cursors.DictCursor)
  18. conn = connection.cursor()
  19.  
  20. url = "https://api-football-v1.p.rapidapi.com/v2/fixtures/date/2020-02-"
  21. querystring = {"timezone":"Europe/Bucharest"}
  22.  
  23. headers = {
  24. 'x-rapidapi-host': "api-football-v1.p.rapidapi.com",
  25. 'x-rapidapi-key': "afb1aaeaaemsh7432a50819ac410p147abejsn6a3da6c306aa"
  26. }
  27.  
  28.  
  29. for date in range(1,16):
  30. response = requests.request("GET", url+str(date), headers=headers, params=querystring)
  31. x = response.json()['api']['fixtures']
  32. allow_contry= ['Italy', 'England', 'Belgium', 'Netherlands' , 'Spain', 'France', 'Austria', 'Germany', 'Romania', 'Turkey', 'Portugal', 'Scotland', 'Greece', 'Switzerland', 'World']#, 'Denmark', 'France', 'Austria'
  33. allow_league_names= ['Championship' ,'Serie A','Serie B' ,'Primera Division' ,'Segunda Division' ,'Ligue 1' ,'Eredivisie' ,'League One', ' Super Lig', 'Lig', 'Primeira Liga', 'Liga I', 'Premiership', 'Super League', 'Super League', 'Bundesliga 1','Bundesliga 2', 'League One', 'Europa League'] #, ,'Superligaen'
  34. for y in x:
  35. if y['league']['country'] in allow_contry:
  36. if y['league']['name'] in allow_league_names:
  37. try:
  38. sql = "INSERT INTO `all_bets` (`fixture_id`,`league_id`,`league_name`,`league_country`,`home`,`away`,`half_home`,`half_away`, `final_home`, `final_away`, `win`, `status`, `date`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s , %s, %s, %s, %s, %s)"
  39. conn.execute(sql, (y['fixture_id'],y['league_id'], y['league']['name'], y['league']['country'], y['homeTeam']['team_name'], y['awayTeam']['team_name'],int(y['score']['halftime'].split('-')[0]),int(y['score']['halftime'].split('-')[1]),int(y['score']['fulltime'].split('-')[0]),int(y['score']['fulltime'].split('-')[1]), "100" ,"status", "2020-02-"+str(date) ))
  40. # print(y['league']['country'], y['league']['name'],y['homeTeam']['team_name'] ,y['awayTeam']['team_name'] )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement