list_of_compounds = list(c('C00001', 'C00002', 'C00003', 'C00004')) get_compound_belongs_to <- function(compound) { url <- paste('https://www.genome.jp/dbget-bin/www_bget?-f+m+cpd:', compound, sep="") page <- read_html(url) node <- html_node(page, '#pathway_tab_1 > ul > li > a') text <- html_text(node) return(text) } get_compound_belongs_to(list_of_compounds)
The get_compound_belongs_to function takes a list of KEGG compound IDs and returns the pathways that these compounds belong to.