通过单击按钮,带有rvest的刮擦表
我正在处理财务数据,我想从此网站网络刮擦数据。 https://www.sikafinance.com/marches/marches/marches/restoriques?s=brvmag = brvmag 。 我想从上面的网站上刮擦表的数据,该数据
•DLPERIOD
•DATER
•DATETO
,最后单击按钮 btcchange =“ OK”。
尝试下面的代码后,我只获取第一张表。 更改开始日期和结束日期时,我希望能够获得其他表。 但是不幸的是,即使我更改了日期,我仍然可以在今天的约会中得到桌子。 有人知道如何恢复整个桌子吗? 我注意到检查他们的网站时,当您更改日期时,它不会在其代码中更改和标签。图像在底部。
我认为整个桌子都可以使用,并且可以为日期提供过滤器(日期之间的差距不超过3个月),
library(httr)
library(rvest)
first_date<-as.Date("2022-02-01")
end_date <- as.Date("2022-03-29")
query_params <- list(dlPeriod = "Journalière",
datefrom = first_date,
dateto = end_date,
btnChange = "OK")
parameter_response <- GET("https://www.sikafinance.com/marches/historiques?s=BRVMAG", query_params)
parameter_response1<- httr::content(parameter_response, as = "text", encoding = "UTF-8")
parameter_response2 <- read_html(parameter_response1)%>%
html_node('#tblhistos')%>%
html_table()
parameter_response2
# Date Clôture `Plus bas` `Plus haut` Ouverture `Volume Titres` `Volume FCFA` `Variation %`
# <chr> <chr> <chr> <chr> <chr> <chr> <int> <chr>
# 1 29/04/2022 312,09 312,09 312,09 312,09 - 0 2,53%
# 2 28/04/2022 304,38 304,38 304,38 304,38 - 0 0,00%
# 3 27/04/2022 304,38 304,38 304,38 304,38 - 0 2,69%
# 4 26/04/2022 296,42 296,42 296,42 296,42 - 0 0,81%
# 5 25/04/2022 294,05 294,05 294,05 294,05 - 0 1,34%
# 6 22/04/2022 290,17 290,17 290,17 290,17 - 0 0,36%
然后我更改日期以查看是否可以获取新桌子,但不幸的是它确实有效。
first_date<-as.Date("2021-02-01")
end_date <- as.Date("2021-04-29")
进行了相同的过程来刮擦新桌子后,我只得到了旧桌子。
I'm working with financial data and i want to scrape data from this site web.
https://www.sikafinance.com/marches/historiques?s=BRVMAG.
I want to scrape the data of a table from above site that takes three arguments
•dlPeriod
•datefrom
•dateto
And finally click on the button
btcChange ="OK".
After trying the code below I only get the first table.
I would like to be able to get the other tables when I change the start and end date.
But unfortunately even if I change the dates I still get the table for today's date.
Does anyone have any idea how to recover the whole table?
I noticed when inspecting their site that when you change the dates, it doesn't change in the and tags in their code. The images are at the bottom.
I think either the whole table is available and it does a filter for the dates(gap between dates must not exceed 3 months)
library(httr)
library(rvest)
first_date<-as.Date("2022-02-01")
end_date <- as.Date("2022-03-29")
query_params <- list(dlPeriod = "Journalière",
datefrom = first_date,
dateto = end_date,
btnChange = "OK")
parameter_response <- GET("https://www.sikafinance.com/marches/historiques?s=BRVMAG", query_params)
parameter_response1<- httr::content(parameter_response, as = "text", encoding = "UTF-8")
parameter_response2 <- read_html(parameter_response1)%>%
html_node('#tblhistos')%>%
html_table()
parameter_response2
# Date Clôture `Plus bas` `Plus haut` Ouverture `Volume Titres` `Volume FCFA` `Variation %`
# <chr> <chr> <chr> <chr> <chr> <chr> <int> <chr>
# 1 29/04/2022 312,09 312,09 312,09 312,09 - 0 2,53%
# 2 28/04/2022 304,38 304,38 304,38 304,38 - 0 0,00%
# 3 27/04/2022 304,38 304,38 304,38 304,38 - 0 2,69%
# 4 26/04/2022 296,42 296,42 296,42 296,42 - 0 0,81%
# 5 25/04/2022 294,05 294,05 294,05 294,05 - 0 1,34%
# 6 22/04/2022 290,17 290,17 290,17 290,17 - 0 0,36%
Then i change the date to see if Can get a New table but unfortunatly it does work.
first_date<-as.Date("2021-02-01")
end_date <- as.Date("2021-04-29")
After doing the same processus to scrape the New table i get only the old one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到一个帖子API请求,称为具有以下参数的历史数据:
'ticker'='brvmag','dedeb'='2022-02-01','datefin'='2022-03-29','xperiod '='0'
我用卸下标头和饼干进行了测试,似乎不需要它们。
I see a POST API request called for historic data with the params as below:
'ticker'= 'BRVMAG', 'datedeb'= '2022-02-01', 'datefin'= '2022-03-29','xperiod'= '0'
I tested with removing headers and cookies and it seems they are not needed.