简体   繁体   中英

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

The link is: http://www.b3.com.br/pt_br/produtos-e-servicos/negociacao/renda-variavel/fundos-de-investimentos/fii/fiis-listados/

I have to click in the "Exportar lista completa de Fundos em CSV" button to download the file

For some reason, the only way i could read the page in R was using

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")

The button "Exportar lista completa de Fundos em CSV" is coming from a different origin, if you open dev tools on chrome you can see that the whole body is in an iframe and its source is https://sistemaswebb3-listados.b3.com.br/fundsPage/7 .

I suggest you

  1. grab the iframe source first then
  2. scrape it to find the link of the 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.

since you can easily get these from website source you can use cheerio to quickly scrape and grab the item from HTML

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM