diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/download_markit_quotes.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/python/download_markit_quotes.py b/python/download_markit_quotes.py new file mode 100644 index 00000000..1823c16b --- /dev/null +++ b/python/download_markit_quotes.py @@ -0,0 +1,43 @@ +import selenium +from selenium.webdriver import Firefox, PhantomJS, FirefoxProfile +from selenium.webdriver.common.action_chains import ActionChains +from selenium.webdriver.common.by import By +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait +import time, os +from config import markit_login, markit_password + +profile = FirefoxProfile() +profile.set_preference('browser.download.folderList', 2) # custom location +profile.set_preference('browser.download.manager.showWhenStarting', False) +profile.set_preference('browser.download.dir', '/tmp') +profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv') + +driver = Firefox(profile) +driver.get("https://markit.com/") +driver.find_element_by_css_selector("a.loginLink").click() +wh = driver.current_window_handle +driver.find_element_by_css_selector("input[name=username]").send_keys(markit_login) +driver.find_element_by_css_selector("input[name=password]").send_keys(markit_password) +driver.find_element_by_css_selector("input[name=Login]").click() +driver.switch_to.window(driver.window_handles[1]) +WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.ID, "provider-frame"))) +menu = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, + "table.menuNavTable td + td div"))) +ActionChains(driver).move_to_element(menu).perform() +hiddenmenu = WebDriverWait(driver, 10).until( + EC.element_to_be_clickable((By.CSS_SELECTOR, + "div.MPopUpMenu div.popupContent table tbody tr:nth-of-type(3) td div"))) +hiddenmenu.click() +WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.NAME, "MFrame"))) +link = driver.find_element_by_css_selector(".searchBg_bottom span:nth-child(1) table:nth-child(1) tbody:nth-child(1) tr:nth-child(1) td:nth-child(2) a:nth-child(1)") +link.click() + +while(True): + total_wait = 0 + while (not os.path.exits("Quotes.csv") or total_wait==10): + time.sleep(1) + total_wait += 1 + +driver.close() |
