[問題] 魚類資料庫爬蟲,爬不出來
[問題類型]:
程式諮詢(我想用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
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.74.161
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1540308654.A.E0D.html
※ 編輯: mary84215 (140.112.74.161), 10/23/2018 23:40:07
※ 編輯: mary84215 (140.112.74.161), 10/23/2018 23:40:39
推
10/24 08:09,
6年前
, 1F
10/24 08:09, 1F
→
10/24 08:10,
6年前
, 2F
10/24 08:10, 2F
→
10/24 08:11,
6年前
, 3F
10/24 08:11, 3F
→
10/24 08:11,
6年前
, 4F
10/24 08:11, 4F
→
10/24 23:54,
6年前
, 5F
10/24 23:54, 5F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章