I'm using RSelenium on my MacBook to scrape publicly available .csv files. None of the other questions posed so far had answers that were particularly helpful for me. Please don't mark this as a duplicate.
With respect to Firefox, I can't disable the dialog box. I've tried a number of different things.
According to Firefox, the MIME type of the file I'm trying to download text/csv; charset=UTF-8. However, executing the following code still elicits the dialog box to appear:
fprof <- makeFirefoxProfile(list(browser.download.dir = "~/Scrape"
,browser.download.folderList = 2L
,browser.download.manager.showWhenStarting = FALSE
,browser.download.manager.showAlertOnComplete = FALSE
,browser.helperApps.neverAsk.openFile = "text/csv; charset=UTF-8"
,browser.helperApps.neverAsk.saveToDisk = "text/csv; charset=UTF-8"))
browser <- remoteDriver(port = 5556, browserName = "firefox", extraCapabilities = fprof)
I've tried a number of different edits, including editing the MIME to text/csv as well as application/octet-stream. Neither work. I've created a Firefox profile with features already in to avoid the dialog box. That's also no luck.
I tried moving to Chrome, but alas...there, I encounter another issue. After 100 items, Chrome won't allow me to automatically download the files. My scraping function is rather complex and the only solution posted to a similar type problem wasn't very clear.
I define the following capabilities for Chrome, but it doesn't disable the 100 limit on downloads.
eCaps <- list(
chromeOptions =
list(prefs = list(
"profile.default_content_settings.popups" = 0L,
"download.prompt_for_download" = FALSE,
"download.default_directory" = "~/Desktop/WebScrape"
)
)
)
browser <- remoteDriver(port = 5556, browserName = "chrome",extraCapabilities = eCaps)
I'm happy to take any suggestions. I've spent hours trying to figure this issue out. Any help is appreciated.
Edit: to provide more details, I'm a researcher and PhD Candidate interested in criminal justice reform. I'm pulling data from http://casesearch.courts.state.md.us/casesearch/ to examine cases of different types and jurisdictions in Maryland. A data request submitted to the Circuit Court has been accepted; however, the custodians may not be able to provide it to me in a reasonable time (up to several months). Therefore, I am scraping the data myself.
The code I wrote so far automatically gets through the terms and conditions page, types in a letter of the alphabet - say A, selects Circuit Court only, chooses a set of dates, picks a jurisdiction, and then searches for all cases. At the bottom of the page, there is an option to download the records in .csv form. I have the code clicking this. I condition all of my code on the presence of error messages. If these error messages pop up, then I go back and update the dates until the message goes away.
Chrome limits me to 100 downloads. Since I posted the code earlier today, I have the records synthesized into a larger .csv file and then delete all similarly named files once it reaches the end of the search dates I have chosen for a particular letter of the alphabet. This will work for most counties. I will run into issues with the Circuit Courts of Anne Arundel County, Baltimore city, Baltimore County, Howard County, and Montgomery County; in those jurisdictions, I essentially have to download per day records given the level of policing and crime in those counties. That means thousands of .csv files. The Chrome limit really makes it cumbersome.
If someone can help me purge this dialog box issue from my R code, then I would be very thankful. I am sure others have or will have the same question.