1

每个星期一,我需要解析最后几周(5 天)“USD RATES 1100”。因此,为此我需要为上周的每一天选择日期,并从系列下拉列表中选择“USD RATES 1100”。我只需要 1 年的期限利率。所以最终答案应该有 5 个 1 年期限的“USD RATES 1100”值。

https://www.theice.com/marketdata/reports/180

from selenium import webdriver
chrome_path = r"C:\Users\vick\Desktop\python_1\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get("https://www.theice.com/marketdata/reports/180")
driver.find_element_by_xpath()
4

2 回答 2

0

最终答案:

from selenium import webdriver
chrome_path = r"C:\Users\vick\Desktop\python_1\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get("https://www.theice.com/marketdata/reports/180")
try:
   driver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div/div/
   div[2]/button').click()
except:
      pass

driver.find_element_by_xpath('//*
[@id="seriesNameAndRunCode_chosen"]/a/span').click()
driver.find_element_by_xpath('//*
[@id="seriesNameAndRunCode_chosen"]/div/ul/li[5]').click()
driver.find_element_by_xpath('//*[@id="reportDate"]').clear()
driver.find_element_by_xpath('//*[@id="reportDate"]').send_keys("27-Jul-
2017") #or whatever date
driver.find_element_by_xpath('//*[@id="selectForm"]/input').click()
driver.execute_script("window.scrollTo(0, document.body.scrollHeight)/2;")
time.sleep(4)
print ( (driver.find_element_by_xpath('//*[@id="report-
content"]/div/div/table/tbody/tr[1]/td[2]').get_attribute('innerHTML')).
strip() )
于 2017-08-03T04:25:01.897 回答
0
from selenium import webdriver
chrome_path = r"C:\Users\vick\Desktop\python_1\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
driver.get("https://www.theice.com/marketdata/reports/180")
try:
  driver.find_element_by_xpath('/html/body/div[3]/div/div[2]/div/div/div[2]/button').click()
except:
  pass

driver.find_element_by_xpath('//*[@id="seriesNameAndRunCode_chosen"]/a/span').click()
driver.find_element_by_xpath('//*[@id="seriesNameAndRunCode_chosen"]/div/ul/li[5]').click()
driver.find_element_by_xpath('//*[@id="reportDate"]').clear()
driver.find_element_by_xpath('//*[@id="reportDate"]').send_keys("27-Jul-2017") #or whatever date
driver.find_element_by_xpath('//*[@id="selectForm"]/input').click()
driver.execute_script("window.scrollTo(0, document.body.scrollHeight)/2;")
print ( driver.find_element_by_xpath('//*[@id="report-content"]/div/div/table/tbody/tr[1]/td[2]').get_attribute('innerHTML') )

这将选择USD RATES 1100、输入日期并提交。您可以循环此过程以输入更多日期。

于 2017-07-30T18:18:50.980 回答