[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
使用者(已经有用R 做过不少作品)
[问题叙述]:
各位大大好,我想在FishBase网站把这种鱼的Human uses爬下来,网址如下方所列
http://www.fishbase.org/summary/Decapterus-maruadsi.html
以此网页为例,我使用套件rvest爬虫,并配合SelectorGadget取得元素的css路径或是xp
ath
原本期待能爬出"Fisheries: highly commercial",但是不知为何总是爬出character(0)
已经试过许多方法,且此网页应该也不是动态网页,但还是不得其解QQ
只好来这里求助各位大大了,谢谢各位
[程式范例]:
rm(list=ls())
library("rvest")
library("xml2")
library("magrittr")
library("httr")
page=read_html("http://www.fishbase.org/summary/Decapterus-maruadsi.html")
page %>% html_nodes(".smallSpace:nth-child(44) span") %>%
html_text()
[环境叙述]:
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.6 (Sierra)
locale:
[1] zh_TW.UTF-8/zh_TW.UTF-8/zh_TW.UTF-8/C/zh_TW.UTF-8/zh_TW.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] httr_1.3.1 magrittr_1.5 rvest_0.3.2 xml2_0.1.2
loaded via a namespace (and not attached):
[1] selectr_0.4-1 R6_2.1.2 tools_3.3.1 curl_3.1 Rcpp_0.12.4
[6] stringi_1.0-1 stringr_1.0.0
[关键字]:
爬虫、rvest