PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 29, 2022

[FIXED] How do I query a website URL from within shinyapp and display the webpage output in shiny

 November 29, 2022     iframe, r, shiny, shinyapps     No comments   

Issue

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.

This is the website I am trying to access, although ideally I'd be able to have the textInput search in the search bar 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%3A0000001&endStageId=ZFS%3A0000044&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)

Solution

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.



Answered By - lz100
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing