-
Notifications
You must be signed in to change notification settings - Fork 2
/
web-s2.py
59 lines (47 loc) · 1.89 KB
/
web-s2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
from webdriver_manager.chrome import ChromeDriverManager
import time
from selenium.webdriver.chrome.options import Options
from datetime import datetime
class Bot:
def __init__(self):
self.driver = webdriver.Chrome(ChromeDriverManager().install())
self.driver.get("https://www.bet365.com/#/AVR/B24/R^1/")
time.sleep(8)
def get_data(self):
self.driver.find_element_by_class_name('vr-ResultsNavBarButton').click()
time.sleep(5)
self.podiumPosition = self.driver.find_elements_by_class_name('vrr-PodiumPlace_Position')
self.podiumPrice = self.driver.find_elements_by_class_name('vrr-Price')
self.podiumRunner = self.driver.find_elements_by_class_name('vrr-ParticipantInfo_Runner')
self.podiumResult = self.driver.find_elements_by_class_name('vrr-ResultParticipant_Text')
Bot.toCSVAndKeepActualData()
def toCSVAndKeepActualData(self):
df_old = pd.read_csv('bet365.csv')
df_new = pd.DataFrame({
'HourAndDate': [ Bot.getHourAndDate()],
'Winner': [self.podiumPosition[0].text],
'Price': [self.podiumPrice[0].text],
'Runner': [self.podiumRunner[0].text],
'Result': [self.podiumResult[1].text]
})
df_new.to_csv('bet365.csv', index=False)
df_merged = df_old.append(df_new)
df_merged.to_csv('bet365.csv', index=False)
print('Data updated')
self.driver.refresh()
def getHourAndDate(self):
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
current_date = now.strftime("%d/%m/%Y")
return current_time + ' ' + current_date
def initBot(self):
while True:
self.get_data()
time.sleep(30)
Bot = Bot()
while True:
Bot.get_data()
time.sleep(190)