Last active
October 30, 2022 03:18
-
-
Save stdsp/5e2d7d32727c322189c6cbbee7031c65 to your computer and use it in GitHub Desktop.
a script which saves a csv file of the 4 details on the https://app.composer.trade/follow page for all symphonies that you follow
This file contains 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
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 pandas as pd | |
import datetime | |
driver = webdriver.Firefox(executable_path="geckodriver.exe") | |
driver.get("https://app.composer.trade/login") | |
def job(): | |
url = "https://app.composer.trade/follow" | |
wait = WebDriverWait(driver, 10) | |
wait.until(EC.url_to_be(url)) | |
#symphony name | |
symps = driver.find_elements(By.CLASS_NAME, "text-lg.mb-1.leading-snug.relative.z-20.pointer-events-none") | |
symps_name = [symp.text for symp in symps] | |
#symphony url | |
symps = driver.find_elements(By.CLASS_NAME, "sr-only") | |
symps_url = [symp.get_attribute("href") for symp in symps] | |
#simulated value | |
sim_vals = driver.find_elements(By.XPATH, "//*[contains(text(), 'Simulated Value')]/following-sibling::node()") | |
sim_vals_txt = [sim_val.text for sim_val in sim_vals] | |
#cumulative return | |
cum_rets = driver.find_elements(By.XPATH, "//*[contains(text(), 'Cumulative Return')]/following-sibling::node()") | |
cum_rets_txt = [cum_ret.text for cum_ret in cum_rets] | |
#today's $ change | |
usd_changes = driver.find_elements(By.XPATH, "//*[contains(text(), \"Today's $ Change\")]/following-sibling::node()") | |
usd_changes_txt = [usd_change.text for usd_change in usd_changes] | |
#today's % change | |
percent_changes = driver.find_elements(By.XPATH, "//*[contains(text(), \"Today's % Change\")]/following-sibling::node()") | |
percent_changes_txt = [percent_change.text for percent_change in percent_changes] | |
prop_names = ["symp_name", "symp_url", "sim_val", "cum_ret", "usd_change", "percent_change"] | |
props = [symps_name, symps_url, sim_vals_txt, cum_rets_txt, usd_changes_txt, percent_changes_txt] | |
df = pd.DataFrame(dict(zip(prop_names, props))) | |
dt_now = datetime.datetime.now() | |
df["datetime"] = dt_now | |
df.to_csv(f"{dt_now.strftime('%d_%m_%Y_%H_%M_%S')}.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i made a few updates to it:
https://gist.github.com/androslee/c55e41227c58f6415b8248c8d9751364
having some issues using the linux chrome webdriver