我正在嘗試抓取ncbi 網(wǎng)站(https://www.ncbi.nlm.nih.gov/ Protein/29436380)來獲取蛋白質(zhì)信息。我需要訪問gene_synonyms 和GeneID 字段。我嘗試使用chrome中的selectorGadget插件和ff中的代碼檢查器找到相關(guān)節(jié)點(diǎn)。我試過這段代碼:我正在嘗試抓取ncbi 網(wǎng)站(https://www.ncbi.nlm.nih.gov/ Protein/29436380)來獲取蛋白質(zhì)信息。我需要訪問gene_synonyms 和GeneID 字段。我嘗試使用chrome中的selectorGadget插件和ff中的代碼檢查器找到相關(guān)節(jié)點(diǎn)。我試過這段代碼:require("dplyr")require("rvest")require("stringr")GIwebPage <- read_html("https://www.ncbi.nlm.nih.gov/protein/29436380")TestHTML <- GIwebPage %>% html_node("div.grid , div#maincontent.col.nine_col , div.sequence , pre.genebank , .feature") %>% html_text(trim = TRUE)然后我嘗試查找相關(guān)文本,但根本不存在。str_extract_all(TestHTML, pattern = "(synonym).{30}") [[1]] character(0)str_extract_all(TestHTML, pattern = "(GeneID:).{30}") [[1]] character(0)我似乎正在訪問的只是右側(cè)列的一些文本內(nèi)容。str_extract_all(TestHTML, pattern = "(protein).{30}") [[1]] [1] "protein codes including ambiguities a" [2] "protein sequence for myosin-9 (NP_00" [3] "protein should not be confused with t" [4] "protein, partial [Homo sapiens]gi|294" [5] "protein codes including ambiguities a"我已經(jīng)嘗試了很多節(jié)點(diǎn)選擇與 html_node() 的組合,以至于我不知道該嘗試什么。該內(nèi)容是否隱藏在我看不到的某些結(jié)構(gòu)中?或者我只是不夠熟練,無法實(shí)現(xiàn)要選擇的節(jié)點(diǎn)?
無法使用rvest和selectorGadget訪問html頁面中的特定內(nèi)容
繁華開滿天機(jī)
2024-01-03 16:32:52