Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import gspread
- from oauth2client.service_account import ServiceAccountCredentials
- import datetime
- import pymysql.cursors
- import requests
- import pprint
- import math
- import datetime
- connection = pymysql.connect(host='localhost',
- user='admin',
- password='admin',
- db='pariuri',
- autocommit=True,
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- conn = connection.cursor()
- url = "https://api-football-v1.p.rapidapi.com/v2/fixtures/date/2020-02-"
- querystring = {"timezone":"Europe/Bucharest"}
- headers = {
- 'x-rapidapi-host': "api-football-v1.p.rapidapi.com",
- 'x-rapidapi-key': "afb1aaeaaemsh7432a50819ac410p147abejsn6a3da6c306aa"
- }
- for date in range(1,16):
- response = requests.request("GET", url+str(date), headers=headers, params=querystring)
- x = response.json()['api']['fixtures']
- allow_contry= ['Italy', 'England', 'Belgium', 'Netherlands' , 'Spain', 'France', 'Austria', 'Germany', 'Romania', 'Turkey', 'Portugal', 'Scotland', 'Greece', 'Switzerland', 'World']#, 'Denmark', 'France', 'Austria'
- 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'
- for y in x:
- if y['league']['country'] in allow_contry:
- if y['league']['name'] in allow_league_names:
- try:
- 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)"
- 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) ))
- # 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