Last active
September 14, 2018 09:20
-
-
Save moonzlo/c012bcb4460c6f3517c277574a2d90a2 to your computer and use it in GitHub Desktop.
parsing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests, json, time, winsound | |
| from bs4 import BeautifulSoup | |
| # очищаем консоль от мусора в виде результатов | |
| # проигрываем звук при появлении ссылки | |
| frequency = 670 # Set Frequency To 2500 Hertz | |
| duration = 1000 # Set Duration To 1000 ms == 1 second | |
| saveResult = [] | |
| proxies = [{"https": "206.81.13.127:8080"}, {"https": "206.81.13.127:8080"}, {"https": "206.81.13.127:8080"} | |
| , {"https": "206.81.13.127:8080"}, {"https": "206.81.13.127:8080"}, {"https": "206.81.13.127:8080"}] | |
| proxiNum = int(0) | |
| def startSnif(): | |
| try: | |
| site = 'https://ap.cdnbetcity.com/api/v1/live/results?rev=3&ver=157&csn=oquoxr' | |
| tets = requests.get(site, proxies=proxies[proxiNum]) | |
| # tets = requests.get(site) | |
| file = json.loads(tets.text) | |
| type = file['reply']['sports']['46']['chmps'] | |
| for i in type.keys(): | |
| game = file['reply']['sports']['46']['chmps'][i]['evts'].keys() | |
| game_name = file['reply']['sports']['46']['chmps'][i]['name_ch'] | |
| for info in game: | |
| num = file['reply']['sports']['46']['chmps'][i]['evts'][info] | |
| names = 'Играют: {} и {}'.format(num['name_ht'],num['name_at']) | |
| # Получаем цифры входящие в состав ссылки | |
| statisticLink = file['reply']['sports']['46']['chmps'][i]['evts'][info]['stat_link'] | |
| s = num['sc_ev'].split(':') | |
| link = num['stat_link'].split(':') | |
| url = 'https://betsbc.com/v3/ru/live/table-tennis/{}/{}'.format(link[0], link[3]) | |
| num1 = int(s[0]) | |
| num2 = int(s[1]) | |
| # Выводим ссылки на матчи 2:0 или 0:2 | |
| if num1 > 1 and num2 == 0: | |
| if link[3] not in saveResult: | |
| # Получаем счёт по очным встречам | |
| scoreLink = 'https://betsbc.com/v3/ru/mstat/{}'.format(statisticLink) | |
| r = requests.get(scoreLink) | |
| soup = BeautifulSoup(r.text, 'html.parser') | |
| # ---------------------------------------------- | |
| # Процесс отсеивания лишних колонок. | |
| filter1 = soup.find_all('td', class_='score co1') | |
| filter2 = soup.find_all('td', class_='score co2') | |
| fil = filter1 + filter2 | |
| find_internal_meeting = soup.find_all('td', class_='score') | |
| result = [] | |
| for x in find_internal_meeting: | |
| if x not in fil: | |
| result.append(x.text) | |
| otsev = 0 | |
| if len(result) >= 5: | |
| for y in result[:5]: | |
| a = y.split() | |
| b = a[0].split(':') | |
| sravnit = [] | |
| sravnit.append(int(b[0])) | |
| sravnit.append(int(b[1])) | |
| if sravnit[0] == int(0) or sravnit[1] == int(0): | |
| otsev += 1 | |
| if otsev <= 1: | |
| winsound.Beep(frequency, duration) # проигрывает звук | |
| print(game_name) | |
| print(names) | |
| print('Ткущий счёт: ', s) | |
| print('Сделать ставку: ', url) | |
| else: | |
| continue | |
| else: | |
| continue | |
| saveResult.append(link[3]) | |
| elif num2 > 1 and num1 == 0: | |
| if link[3] not in saveResult: | |
| # Получаем счёт по очным встречам | |
| scoreLink = 'https://betsbc.com/v3/ru/mstat/{}'.format(statisticLink) | |
| r = requests.get(scoreLink) | |
| soup = BeautifulSoup(r.text, 'html.parser') | |
| # --------------------------------------------- | |
| # Процесс отсеивания лишних колонок. | |
| filter1 = soup.find_all('td', class_='score co1') | |
| filter2 = soup.find_all('td', class_='score co2') | |
| fil = filter1 + filter2 | |
| find_internal_meeting = soup.find_all('td', class_='score') | |
| result = [] | |
| for x in find_internal_meeting: | |
| if x not in fil: | |
| result.append(x.text) | |
| otsev = 0 | |
| if len(result) >= 5: | |
| for y in result[:5]: | |
| a = y.split() | |
| b = a[0].split(':') | |
| sravnit = [] | |
| sravnit.append(int(b[0])) | |
| sravnit.append(int(b[1])) | |
| if sravnit[0] == int(0) or sravnit[1] == int(0): | |
| otsev += 1 | |
| if otsev <= 1: | |
| winsound.Beep(frequency, duration) # проигрывает звук | |
| print(game_name) | |
| print(names) | |
| print('Ткущий счёт: ', s) | |
| print('Сделать ставку: ', url) | |
| else: | |
| continue | |
| else: | |
| continue | |
| saveResult.append(link[3]) | |
| saveResult.append(link[3]) | |
| except Exception as error: | |
| print('Ошибочка вышла: ', error) | |
| while True: | |
| # контролируем количество использованней проксей. | |
| if proxiNum > 5: | |
| # если число привысило НОМЕР позиции в списке, то всё начинаем с начала | |
| proxiNum = 0 | |
| elif proxiNum < 6: | |
| print(proxiNum) | |
| startSnif() | |
| time.sleep(2) # Время ожидания обновления страницы (в сек.) | |
| proxiNum += 1 # Переход на следующую проксю ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment