簡體   English   中英

有沒有辦法在不使用 R 中的 RSelenium 的情況下從“網站按鈕單擊”下載 CSV 文件?

[英]Is there a way to download a CSV file from "website button click" without using RSelenium in R?

鏈接為: http://www.b3.com.br/pt_br/produtos-e-servicos/negociacao/renda-variavel/fundos-de-investimentos/fii/fiis-listados/

我必須單擊“Exportar lista completa de Fundos em CSV”按鈕來下載文件

出於某種原因,我可以閱讀 R 中的頁面的唯一方法是使用

url = "http://www.b3.com.br/pt_br/produtos-e-servicos/negociacao/renda-variavel/fundos-de-investimentos/fii/fiis-listados/"
download.file(url1, destfile = "scrapedpage.html", quiet=TRUE)

content <- read_html("scrapedpage.html")

“Exportar lista completa de Fundos em CSV”按鈕來自不同的來源,如果您在 chrome 上打開開發工具,您可以看到整個主體位於 iframe 中,其來源是https://sistemaswebb3-listados.b3。 com.br/fundsPage/7

我建議你

  1. 先獲取 iframe 源然后
  2. 刮它以找到btn的鏈接。

For this case it was https://sistemaswebb3-listados.b3.com.br/fundsProxy/fundsCall/GetListFundDownload/eyJ0eXBlRnVuZCI6NywicGFnZU51bWJlciI6MSwicGFnZVNpemUiOjIwfQ== this will csv data all you have to do is convert it to csv.

由於您可以輕松地從網站源獲取這些內容,因此您可以使用cheerio快速從 HTML 抓取項目

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM