Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

library(RDCOMClient)

url <- "https://fcainfoweb.nic.in/reports/report_menu_web.aspx"


IEApp <- COMCreate("InternetExplorer.Application")
IEApp[['Visible']] <- TRUE
IEApp$Navigate(url)
Sys.sleep(5)
doc <- IEApp$Document()

clickEvent <- doc$createEvent("MouseEvent")


clickEvent$initEvent("click", TRUE, FALSE)

web_Obj <- doc$querySelector('#ctl00_MainContent_Rbl_Rpt_type > tbody > tr:nth-


child(1) > td > label')
web_Obj$dispatchEvent(clickEvent)
Sys.sleep(2)

web_Obj_Select <- doc$querySelector('#ctl00_MainContent_Ddl_Rpt_Option0')


web_Obj_Select[["Value"]] <- "Daily Prices"
web_Obj_Select$FireEvent("onchange")
Sys.sleep(2)

web_Obj_Date <- doc$querySelector('#ctl00_MainContent_Txt_FrmDate')


web_Obj_Date[["Value"]] <- "14/09/2022"
Sys.sleep(2)

web_Obj_Get_Data <- doc$querySelector('#ctl00_MainContent_btn_getdata1')


web_Obj_Get_Data$dispatchEvent(clickEvent)

Sys.sleep(120)

html_Content <- doc$documentElement()$innerHtml()


read_html(html_Content) %>% html_table()

[[1]]
# A tibble: 276 x 6,177
X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13
X14 X15 X16 X17 X18 X19 X20 X21 X22 X23 X24
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
<chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
1 "" NA NA NA NA NA NA NA NA NA NA NA NA NA
NA NA NA NA NA NA NA NA NA NA
2 "Dep~ Depa~ Date~ Dail~ Unit~ "Cen~ Cent~ Rice Wheat Atta~ Gram~ Tur/~ Urad~
Moon~ Maso~ Sugar Milk~ Grou~ Must~ Vana~ Soya~ Sunf~ Palm~ Gur
3 "Dep~ Date~ Dail~ Unit~ NA NA NA NA NA NA NA NA NA NA
NA NA NA NA NA NA NA NA NA NA
4 "Dat~ Dail~ Unit~ NA NA NA NA NA NA NA NA NA NA NA
NA NA NA NA NA NA NA NA NA NA
5 "Cen~ Cent~ Rice Wheat Atta~ "Gra~ Tur/~ Urad~ Moon~ Maso~ Sugar Milk~ Grou~
Must~ Vana~ Soya~ Sunf~ Palm~ Gur Tea ~ Salt~ Pota~ Onion Toma~
6 "Cen~ Rice Wheat Atta~ Gram~ "Tur~ Urad~ Moon~ Maso~ Sugar Milk~ Grou~ Must~
Vana~ Soya~ Sunf~ Palm~ Gur Tea ~ Salt~ Pota~ Onion Toma~ NA
7 "Ave~ 38.15 31.15 36.07 74.28 "111~ 108.~ 103.~ 97.12 42.57 53.68 187.~ 170.4
152.~ 152.~ 173.~ 126.~ 51.41 278.~ 20.74 28.36 26.23 41.81 NA
8 "Max~ 61 45 65 120 "142" 175 145 134 55 80 250 255
227 218 238 188 120 547 30 53 60 73 NA
9 "Min~ 22 18 24 57 "75" 73 80 77 36 32 155 140
103 125 141 98 35 123 8 13 12 17 NA
10 "Mod~ 40 25 35 70 "110" 100 97.5 90 40 48 186.~ 162
160 150 190 137 46 240 25 25 28 40 NA
# ... with 266 more rows, and 6,153 more variables: X25 <chr>, X26 <chr>, X27
<chr>, X28 <chr>, X29 <chr>, X30 <chr>, X31 <dbl>, X32 <dbl>,
# X33 <dbl>, X34 <dbl>, X35 <dbl>, X36 <dbl>, X37 <dbl>, X38 <dbl>, X39 <dbl>,
X40 <dbl>, X41 <dbl>, X42 <dbl>, X43 <dbl>, X44 <dbl>,
# X45 <dbl>, X46 <dbl>, X47 <dbl>, X48 <chr>, X49 <dbl>, X50 <dbl>, X51 <dbl>,
X52 <dbl>, X53 <chr>, X54 <int>, X55 <int>, X56 <int>,
# X57 <int>, X58 <int>, X59 <int>, X60 <int>, X61 <int>, X62 <int>, X63 <int>,
X64 <int>, X65 <int>, X66 <int>, X67 <int>, X68 <int>,
# X69 <int>, X70 <int>, X71 <chr>, X72 <int>, X73 <int>, X74 <int>, X75 <int>,
X76 <chr>, X77 <int>, X78 <int>, X79 <int>, X80 <int>,
# X81 <int>, X82 <int>, X83 <int>, X84 <int>, X85 <int>, X86 <int>, X87 <int>,
X88 <int>, X89 <int>, X90 <int>, X91 <int>, X92 <int>,
# X93 <int>, X94 <chr>, X95 <int>, X96 <int>, X97 <int>, X98 <int>, X99 <chr>,
X100 <int>, X101 <dbl>, X102 <int>, X103 <int>, X104 <int>, ...
# i Use `print(n = ...)` to see more rows, and `colnames()` to see all variable
names

You might also like