我尝试使用以下命令从R中的Quandl API查询ETF每日价格数据(SPY):
spy <- read.csv("https://www.quandl.com/api/v3/datasets/WIKI/SPY.csv")
但是我收到以下错误消息:
文件错误(文件,&#34; rt&#34;):无法打开连接
另外:警告信息:
在档案中(文件,&#34; rt&#34;):
网址&#39; https://www.quandl.com/api/v3/datasets/WIKI/SPY.csv&#39;:状态为&#39; 404 Not Found&#39;
同样的命令适用于AAPL等股票,但不适用于ETF。 ETF数据不可用或保存在另一个数据库中吗?
答案 0 :(得分:1)
我使用网页抓取(from bs4 import BeautifulSoup
from selenium import webdriver
url = 'https://ad.nl'
# launch firefox with your url above
# note that you could change this to some other webdriver (e.g. Chrome)
driver = webdriver.Chrome()
driver.get(url)
# click the "accept cookies" button
btn = driver.find_element_by_name('action')
btn.click()
# grab the html. It'll wait here until the page is finished loading
html = driver.page_source
# parse the html soup
soup = BeautifulSoup(html.lower(), "html.parser")
articles = soup.findAll("article")
for i in articles:
article = driver.find_element_by_class_name('ankeiler')
hrefs = article.find_element_by_css_selector('a').get_attribute('href')
print(hrefs)
driver.quit()
)查询免费股票网站的ETF价格。以下代码获取WKN(我想是ISIN)并返回历史价格:
rvest
由reprex package(v0.3.0)于2020-04-21创建