Reputation: 1618
What I am trying to do with RSelenium
package is,
Step:1 Access a website - My own electric utility provider
Step:2 Access my account by explicitly providing my username and password (That's the reason I am unable to share the code)
Step:3 I click 'VIEW MY BILL'. The bill is displayed in pdf format.
Is there a way to download that file and save to specific folder?
When I used download.file()
command, it does not save the document, rather I get a 3KB pdf file that I am not able to open. Adobe Reader says that there is an error reading the document.
Possible method that I tried: 1. Right clicking, Pressing down arrow four times and then get to 'SAVE PAGE AS' click Enter.
But then it pops a dialog box asking for file name and location and I am not able to enter those details via RSelenium and save the file.
Example code: Some random PDF found online.
url<- "http://www.immigrationpolicy.org/sites/default/files/docs/how_us_immig_system_works.pdf"
setwd("C:/Users/king/Desktop/bill")
library(RSelenium)
library(downloader)
checkForServer()
startServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate(url)
Upvotes: 1
Views: 2299
Reputation: 1618
I found the answer on continuous research.
Firstly check whether Rtools is installed (Found the answer using this link)
Then updated my program
cprof<-makeFirefoxProfile(list(
"pdfjs.disabled"=TRUE,
"plugin.scan.plid.all" = FALSE,
"plugin.scan.Acrobat" = "99.0",
"browser.helperApps.neverAsk.saveToDisk"='application/pdf',
))
remDr <- remoteDriver(extraCapabilities=cprof)
Trying still to change the download folder which I am not able to find yet. I found the answer from THIS link
Upvotes: 1