Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, re
- from time import sleep as wait
- import pymysql.cursors
- connection = pymysql.connect(host='localhost',
- user='root',
- password='',
- db='job-cash',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- def checkdb(loc, player, player2):
- with connection.cursor() as cursor:
- mycursor = connection.cursor()
- sql = "SELECT * FROM tennis WHERE Player_1 = %s"
- adr = (player)
- mycursor.execute(sql, adr)
- print(mycursor.rowcount)
- if not mycursor.rowcount:
- cursor = connection.cursor()
- sql = "SELECT * FROM tennis "
- cursor.execute(sql)
- oneRow = cursor.fetchone()
- print("Row Result: ", oneRow)
- cursor = connection.cursor()
- sql = "Insert into tennis (Location, Player_1, Player_2) " \
- + " values (%s, %s, %s) "
- cursor.execute(sql, (loc, player, player2))
- connection.commit()
- url = 'https://mobvhj.xyz/LiveFeed/Mb_BestGamesExtZip'
- data = {
- 'count': 1000,
- 'country': 2,
- 'grMode': 3
- }
- request = requests.Session()
- info = request.get(url, params=data)
- games = info.json()['Value']
- num = 1
- while num < 10:
- for game in games:
- if ('SC' in game) and ('COP' in game['SC']):
- try:
- if 'Гейм' in game['SC']['COP']:
- print(game['L'], game['MIO']['Loc'], game['MIO']['TSt'])
- print(game['O1'], 'vs.', game['O2'])
- gg = re.split(r'\|', game['SC']['COP'])
- gg.remove('')
- print(gg)
- if gg[0].split()[-1] != '40':
- text = 'Внимание поступил сигнал!' + "\n" + game['L'] + game['MIO']['Loc'] + game['MIO'][
- 'TSt'] + '\n' + game['O1'] + 'vs.' + game['O2'] + '\n' + 'Следующий гейм 40:40 - нет'
- #r = requests.get(
- # 'https://api.telegram.org/bot710029530:AAEWIhpzU74kzxfEesjk6hOv9mItxdd8xLE/sendmessage?chat_id=460960819&text=' + text)
- checkdb(game['L'], game['O1'], game['O2'])
- wait(30)
- print('отправил')
- print('\n')
- except Exception as err:
- #print(err)
- pass
- wait(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement