Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nealhaddaway committed Apr 12, 2022
1 parent cf66f2e commit 7be6fdd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
22 changes: 15 additions & 7 deletions inst/shiny-examples/greylitsearcher/app.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ ui <- navbarPage("greylitsearcher", id = "tabs",
column(10,
h2('GreyLitSearcher'),
br(),
'Welcome to GreyLitSearcher, a web-based tool for performing systematic and transparent searches of organisational websites.'
'Welcome to GreyLitSearcher, a web-based tool for performing systematic and transparent searches of organisational websites.',
shinybusy::add_busy_spinner(spin = "fading-circle", color = "#bababa", margins = c(70, 20))
)
)
),
Expand All @@ -43,7 +44,6 @@ ui <- navbarPage("greylitsearcher", id = "tabs",
),
column(5,
splitLayout(
#actionButton("google", "Google", class = "btn-primary"),
actionButton("google", "Google", class = "btn-primary")
)
),
Expand All @@ -65,7 +65,6 @@ ui <- navbarPage("greylitsearcher", id = "tabs",
br(),
br(),
textOutput('save_report')
#downloadButton('download_files', 'Download saved files as .zip',icon = icon("file-download"))
)
)
),
Expand All @@ -75,16 +74,16 @@ ui <- navbarPage("greylitsearcher", id = "tabs",
column(10,
h2('Scrape data from the downloaded search results'),
br(),
add_busy_spinner(spin = "fading-circle", color = "#19d0fc", margins = c(70, 20)),
'Now, we can scrape search results based on patterns in the HTML code.',
hr(),
actionButton("scrape_HTMLs", "Scrape the results HTMLs"),
br(),
br(),
textOutput('scrape_report'),
br(),
dataTableOutput('data')
#downloadButton('download_files', 'Download saved files as .zip',icon = icon("file-download"))
dataTableOutput('data'),
br(),
downloadButton('downloadData', 'Download results as CSV', icon = icon("file-download"))
)
)
)
Expand Down Expand Up @@ -127,7 +126,7 @@ server <- function(input, output) {
observeEvent(input$download_HTMLs, {
htmls <- list()
for(i in 1:length(rv$links[,4])){
html <- save_html((rv$links[,4])[i], pause = 3, backoff = FALSE)
html <- save_html((rv$links[,4])[i], pause = 0.5, backoff = FALSE)
htmls <- c(htmls, html)
}
rv$htmls <- htmls
Expand Down Expand Up @@ -156,6 +155,15 @@ server <- function(input, output) {
output$save_report <- renderText({
paste0('A total of ', nrow(rv$data),' search results have been exported and are shown in the table below.')
})

output$downloadData <- downloadHandler(
filename = function() {
paste("results.csv", sep = "")
},
content = function(file) {
write.csv(rv$data, file, row.names = FALSE)
})

})

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: greylitsearcher
title:
username:
account: estech
server: shinyapps.io
hostUrl: https://api.shinyapps.io/v1
appId: 6062911
bundleId: 5789735
url: https://estech.shinyapps.io/greylitsearcher/
when: 1649756008.93405
lastSyncTime: 1649756008.93407
6 changes: 3 additions & 3 deletions inst/shiny-examples/greylitsearcher/save_htmls.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' for clarity. Files are saved to the working directory. A pause notification is printed to the
#' console.
#' @export
save_html <- function(url, path = '', pause = 2, backoff = TRUE){
save_html <- function(url, path = '', pause = 0.5, backoff = TRUE){
t0 <- Sys.time()

pause <- pause * runif(1, 0.5, 1.5)
Expand Down Expand Up @@ -73,7 +73,7 @@ save_html <- function(url, path = '', pause = 2, backoff = TRUE){
#' @export
save_htmls <- function(urls,
path = '',
pause = 4,
pause = 0.5,
backoff = FALSE){
t0 <- Sys.time()
#htmls <- as.list(mapply(save_html,
Expand All @@ -83,7 +83,7 @@ save_htmls <- function(urls,
# backoff))
htmls <- list()
for(i in 1:length(urls)){
html <- save_html(urls[i], pause = 3, backoff = FALSE)
html <- save_html(urls[i], pause = 0.5, backoff = FALSE)
htmls <- c(htmls, html)
}
t1 <- Sys.time()
Expand Down
Binary file added inst/shiny-examples/greylitsearcher/www/hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7be6fdd

Please sign in to comment.