html - 有没有办法在不使用 R 中的 RSelenium 的情况下从“网站按钮单击”下载 CSV 文件?
问题描述
我必须单击“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。
我建议你
- 先获取 iframe 源,然后
- 刮它以找到btn的链接。
对于这种情况,它是https://sistemaswebb3-listados.b3.com.br/fundsProxy/fundsCall/GetListFundDownload/eyJ0eXBlRnVuZCI6NywicGFnZU51bWJlciI6MSwicGFnZVNpemUiOjIwfQ== 这将 csv 数据您所要做的就是将其转换为 csv。
由于您可以轻松地从网站源代码中获取这些内容,因此您可以使用cheerio从 HTML 中快速抓取和抓取项目
推荐阅读
- python - 使用带有参数的 url_for 进行烧瓶重定向
- python - Python:如何根据查询中的文件日期通过“pyodbc.connect”或其他方式从一个数据库切换到另一个数据库?
- flutter - 如何将应用栏设置在页面顶部的状态栏下方?
- reactjs - gatsby-theme ReactJS 应用程序的平均构建时间是多少
- javascript - 如何将指数数传播到数组?
- mongodb - MongoDB 中的搜索查询
- azure - Azure Functions 应用程序的 Cosmosdb 触发器
- python - 无法使用带有 django 的 ssl 客户端证书连接到本地主机上的 postgresql
- symfony - 如何使用 Swiftmailer 和 Symfony 从 Command 发送 smtp 电子邮件
- android - CircleCi emulator64-arm:找不到命令