-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.py
62 lines (52 loc) · 2.07 KB
/
script.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
57
58
59
60
61
62
import time
import json
import pandas as pd
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from analysis import analysis
import time
def main():
driver = setup()
fetch(driver)
def setup():
print("----- Setting Up -----")
options = webdriver.FirefoxOptions()
options.set_headless()
driver = webdriver.Chrome("/Users/tusharchopra/Desktop/Tushar/Work/Development/Websites/geckodriver", chrome_options=options)
return driver
def fetch(driver):
print("----- Fetching -----")
driver.get("https://roobet.com/crash")
driver.set_window_size(1920, 1200)
time.sleep(5)
driver.find_element_by_tag_name('body').send_keys(Keys.TAB)
driver.find_element_by_tag_name('body').send_keys(Keys.TAB)
driver.find_element_by_tag_name('body').send_keys(Keys.TAB)
driver.find_element_by_tag_name('body').send_keys(Keys.ENTER)
actions = ActionChains(driver)
#actions.move_by_offset( 795, 718).click().perform()
a = driver.find_element(By.CSS_SELECTOR, ".tick_2dJyV:nth-child(1)").text
new_csv()
df = pd.DataFrame([[a, pd.datetime.now()]], columns=(["Crash Point"], ["datetime"]))
df.to_csv("scraped.csv", mode='a', header=False)
anal = analysis("scraped.csv")
while True:
b = driver.find_element(By.CSS_SELECTOR, ".tick_2dJyV:nth-child(1)").text
if b != a:
a = b
print("---- Last Crash: " + str(b))
bdf = pd.DataFrame([[b, pd.datetime.now()]], columns=(["Crash Point"], ["datetime"]))
bdf.to_csv("scraped.csv", mode='a', header=False)
b = b[:-1]
b = float(b)
anal.main(b, 1.5)
def new_csv():
df = pd.read_csv('scraped.csv')
df.to_csv("scraped.csv", index=False)
if __name__ == "__main__":
main()