Home > Net >  How do I query a website URL from within shinyapp and display the webpage output in shiny
How do I query a website URL from within shinyapp and display the webpage output in shiny

Time:11-20

I'd like for users of my app to be able to textInput a gene (eg. alcama) and then view the website output within the app. I am running the app locally.

enter image description here although I think that's going to be far more complicated than I'm imagining as the gene's are all ID'd eg. https://zfin.org/ZDB-GENE-990415-30 rather than using the conventional name (alcama)

I have posted the relevant snippet of my code to attempt this, however it's just resulting in a blank box within the app when I type in eg. alcama.

library(shiny)
ui <- fluidPage(title = "Lab Data",
                           sidebarPanel(
                             selectInput("GEcelltype", "Choose a Cell Type:", 
                                         choices = c("MG", "CMZ", "RPE", "Cones", 'RGC', 'Whole Eye')),
                             
                             textInput(inputId = 'GEgene', label = "Plot Expression, please type gene (all lowercase)", value = "", width = NULL, placeholder = 'EG: alcama'), 
                             sliderInput("min", "Select Minimum Expression Cutoff",
                                         min = 0, max = 5, value = 0
                             ),
                             
                             
                           ),#sidebarpanel
                mainPanel(
                  fluidRow( htmlOutput("frame")),
                ) #mainpanel
                           
)# fluidpage

server <- function(input, output, session) {
  observe({ 
    query <- input$GEgene
    test <<- paste0("https://zfin.org/action/expression/results?rows=25&geneField=",query,"&authorField=&anatomyTermIDs=&anatomyTermNames=&searchTerm=&includeSubstructures=true&_includeSubstructures=on&startStageId=ZFS:0000001&endStageId=ZFS:0000044&assayName=&onlyWildtype=true&_onlyWildtype=on&_onlyReporter=on&_onlyFiguresWithImages=on&journalType=ALL")
  })
  output$frame <- renderUI({
    input$GEgene
    my_test <- tags$iframe(src=test, height=600, width=900)
    print(my_test)
    my_test
  })
}

shinyApp(ui = ui, server = server)

CodePudding user response:

This website has X-Frame-Options: SAMEORIGIN, which means they don't allow you to embed their content in an iframe. You can search their documents to see if they have special URLs to allow you embed. If not, there is nothing you can do.

  • Related