【发布时间】:2019-09-12 02:28:11
【问题描述】:
我正在尝试抓取 Finance.yahoo.com 并下载数据文件。具体来说,这个网址:https://finance.yahoo.com/quote/AAPL/history?p=AAPL
我想在这里完成两个目标:
- 我想将数据时间段参数设置为“Max”,我认为我需要使用 Selenium 和
- 想要下载并保存嵌入在检查“下载数据”时出现的 href 中的数据文件。
到目前为止,我无法访问单击“Max”所需的下拉菜单,也无法找到下载文件所需的 href。
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument('--log-level=3')
stock = input()
base_url = 'https://finance.yahoo.com/quote/{}/history?p=
{}'.format(stock,stock)
driver = webdriver.Chrome()
driver.get(base_url)
driver.maximize_window()
driver.implicitly_wait(4)
driver.find_element_by_class_name("Fl(end) Mt(3px) Cur(p)").click()
time.sleep(4)
driver.quit()
【问题讨论】:
-
请包含您当前的代码。有很多 Stackoverflow 示例可以帮助您与 Yahoo Finance 合作。如果我们看不到您的代码,我们将无法帮助您修复它。
-
当然!我已经添加了我当前的代码 - 我正在尝试找到“下载数据”href,以便我可以下载数据并在熊猫中执行一些基本操作。
标签: python web-scraping finance