From 775c88f380f07a09bd9a2d36ced02995e3b97186 Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 17 Oct 2021 11:14:40 -0600 Subject: [PATCH] Initial commit --- .gitattributes | 2 + edgewonk_min_selenium.py | 89 ++++++++++++++++++++++++++++ edgewonk_mine_bs4.py | 18 ++++++ index.html | 125 +++++++++++++++++++++++++++++++++++++++ output.html | 1 + output.txt | 23 +++++++ 6 files changed, 258 insertions(+) create mode 100644 .gitattributes create mode 100644 edgewonk_min_selenium.py create mode 100644 edgewonk_mine_bs4.py create mode 100644 index.html create mode 100644 output.html create mode 100644 output.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/edgewonk_min_selenium.py b/edgewonk_min_selenium.py new file mode 100644 index 0000000..3710abc --- /dev/null +++ b/edgewonk_min_selenium.py @@ -0,0 +1,89 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +import sys + +LOGIN_URL = "https://edgewonk.app/login" +DRIVER_PATH = '/Users/talksik/Downloads/chromedriver' + +driver = webdriver.Chrome(executable_path=DRIVER_PATH) +wait = WebDriverWait(driver, 10) + +# Login functionality +driver.get(LOGIN_URL) +MY_EMAIL = 'patel.arjun50@gmail.com' +MY_PASSWORD = '@4kLew2!JG!9FK!' +email = driver.find_element_by_id('mat-input-0').send_keys(MY_EMAIL) +password = driver.find_element_by_id('mat-input-1').send_keys(MY_PASSWORD) +driver.find_element_by_xpath('//button').click() + +# select second account - the one I mainly want to mine +second_account = wait.until( + EC.presence_of_all_elements_located((By.CSS_SELECTOR, 'button[mat-button]')) +) +second_account[2].click() +print('clicked the second account') + +# go through each account to mine each one as a wrapper for loop +# in the future +# accounts_list = driver.find_elements_by_xpath('//@mat-button') +# print(accounts_list) + +# Navigate to the Journal Page +journal_nav = wait.until( + EC.presence_of_element_located((By.CSS_SELECTOR, "a[href='/journal']")) +) +journal_nav.click() +print('navigating to the trade journal page') + + +# Mine each trade in each page +# mine each page +is_last_page = False +while not is_last_page: + # mine each trade in the current page + driver.implicitly_wait(2) # seconds + + trades_on_this_page = wait.until( + EC.presence_of_all_elements_located((By.CSS_SELECTOR, "div.ag-row[role='row'][row-index]")) + ) + + # if the next page button is disabled, stop + is_last_page = wait.until( + EC.presence_of_element_located((By.CSS_SELECTOR, "div[ref='btNext']")) + ) + is_last_page = is_last_page.get_attribute('aria-disabled') == 'true' + + for trade_element in trades_on_this_page: + # print all data that I need first + row_index = trade_element.get_attribute('row-index') + print(row_index) + + grid_cells = trade_element.find_elements_by_css_selector("span") + # for grid_cell in grid_cells: + # print(grid_cell.text()) + # dump current trade into csv + # click on the trade to get more metadata + # dump more data that I need + # click on cancel + + # navigate to the next page if not the last_page + if not is_last_page: + next_page_arrow = driver.find_element_by_css_selector("div[ref='btNext']") + next_page_arrow.click() + print('going to the next page for more trades') + else: + print('done...last page') + + +# print(driver.page_source) + +# original_stdout = sys.stdout # Save a reference to the original standard output + +# # output to file in same directory +# with open('output.html', 'w') as f: +# sys.stdout = f # Change the standard output to the file we created. +# print('This message will be written to a file.') +# sys.stdout = original_stdout # Reset the standard output to its original value + diff --git a/edgewonk_mine_bs4.py b/edgewonk_mine_bs4.py new file mode 100644 index 0000000..b4f0586 --- /dev/null +++ b/edgewonk_mine_bs4.py @@ -0,0 +1,18 @@ +from bs4 import BeautifulSoup +import requests +import sys + +login_URL = "https://edgewonk.app/login" +page = requests.get(login_URL) + + +print('This message will be displayed on the screen.') + +original_stdout = sys.stdout # Save a reference to the original standard output + +# output to file in same directory +with open('output.html', 'w') as f: + sys.stdout = f # Change the standard output to the file we created. + print('This message will be written to a file.') + print(page.text) + sys.stdout = original_stdout # Reset the standard output to its original value diff --git a/index.html b/index.html new file mode 100644 index 0000000..4d325dc --- /dev/null +++ b/index.html @@ -0,0 +1,125 @@ + +
+ Trade Data +
+ + + +
+
+ + +
+ + + +
+
+ + + +
+ + + + +
+ + diff --git a/output.html b/output.html new file mode 100644 index 0000000..f7da5e4 --- /dev/null +++ b/output.html @@ -0,0 +1 @@ +This message will be written to a file. diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..92f03f6 --- /dev/null +++ b/output.txt @@ -0,0 +1,23 @@ +This message will be written to a file. + + + + + + Edgewonk Trading Journal App + + + + + + + + + + + + + +