Advertisement
Guest User

Untitled

a guest
May 3rd, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.45 KB | None | 0 0
  1. import requests, re
  2. from time import sleep as wait
  3. import pymysql.cursors
  4. import datetime
  5. connection = pymysql.connect(host='localhost',
  6.                              user='root',
  7.                              password='',
  8.                              db='job-cash',
  9.                              charset='utf8mb4',
  10.                              cursorclass=pymysql.cursors.DictCursor)
  11.  
  12.  
  13. def checkdb(loc, player, player2):
  14.     mycursor = connection.cursor()
  15.     sql = "SELECT * FROM tennis WHERE Player_1 = %s and Player_2 = %s"
  16.     adr = (player, player2)
  17.     mycursor.execute(sql, adr)
  18.     print(mycursor.rowcount)
  19.     if not mycursor.rowcount or mycursor.rowcount == 0:
  20.         text = '%F0%9F%92%B0 Внимание поступил сигнал! %F0%9F%92%B0' + "\n" + '%F0%9F%94%9C ' + game['L'] + game['MIO']['Loc'] + game['MIO'][
  21.             'TSt'] + '\n' + '%F0%9F%92%AA' + game['O1'] + ' %F0%9F%86%9A ' + game['O2'] + '\n' + 'Следующий гейм 40:40 - нет'
  22.         r = requests.get(
  23.             'https://api.telegram.org/bot710029530:AAEWIhpzU74kzxfEesjk6hOv9mItxdd8xLE/sendmessage?chat_id=-1001292519649&text=' + text)
  24.         cursor = connection.cursor()
  25.         now = datetime.date.today()
  26.         sql = "Insert into tennis (Location, Player_1, Player_2, date) " \
  27.               + " values (%s, %s, %s, %s) "
  28.         cursor.execute(sql, (loc, player, player2, now))
  29.         connection.commit()
  30.  
  31. num = 1
  32. while num < 10:
  33.     url = 'https://mobvhj.xyz/LiveFeed/Mb_BestGamesExtZip'
  34.     data = {
  35.         'count': 1000,
  36.         'country': 2,
  37.         'grMode': 3
  38.     }
  39.     request = requests.Session()
  40.     info = request.get(url, params=data)
  41.     games = info.json()['Value']
  42.     for game in games:
  43.         if ('SC' in game) and ('COP' in game['SC']):
  44.             try:
  45.                 if 'Гейм' in game['SC']['COP']:
  46.                     print(game['L'], game['MIO']['Loc'], game['MIO']['TSt'])
  47.                     print(game['O1'], ' vs ', game['O2'])
  48.                     gg = re.split(r'\|', game['SC']['COP'])
  49.                     gg.remove('')
  50.                     print(gg)
  51.                     print('\n')
  52.                     if gg[0].split()[-1] == '40' and gg[1].split()[-1] == '40':
  53.                         checkdb(game['L'], game['O1'], game['O2'])
  54.                         print('отправил')
  55.                     print('\n')
  56.             except Exception as err:
  57.                 #print(err)
  58.                 pass
  59.     wait(30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement