[問題] 爬蟲請教
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
新手
[問題敘述]:
想爬網頁上的淨值部分
[程式範例]:
主要是我透過SelectorGadget 去讀網頁裡面的html
但是無法成功,想請教各位先進是哪裡要調整。
library(rvest)
library(dplyr)
fburl <- "https://goo.gl/P6bNVs"
out <- read_html(fburl) %>% html_nodes(".FsitScriptTableTd:nth-child(4)") %>%
html_text()
http://imgur.com/a/ETYKQ
另外一個網址是透過證交所網頁,但是也是一樣的問題
tseurl <- "http://mis.twse.com.tw/stock/etf_nav.jsp?ex=tse"
out <- read_html(fburl) %>%html_nodes("td:nth-child(5)") %>% html_text()
out
http://imgur.com/a/YWImj
雖然很粗淺但是我還是有些疑問~
用這套去爬一些簡單的網頁都還過得去
雖然目前遇到中文仍有亂碼問題,但是爬數字的話中文可以先暫且拋棄~
若先進願意教學編碼問題也非常感謝
不好意思麻煩大家
[環境敘述]:
請提供 sessionInfo() 的輸出結果,
裡面含有所有你使用的作業系統、R 的版本和套件版本資訊,
讓版友更容易找出錯誤
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1
[關鍵字]:
rvest 爬蟲
選擇性,也許未來有用
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.160.95.184
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1483962738.A.506.html
→
01/10 06:58, , 1F
01/10 06:58, 1F
→
01/10 08:46, , 2F
01/10 08:46, 2F
→
01/10 12:31, , 3F
01/10 12:31, 3F
→
01/10 12:33, , 4F
01/10 12:33, 4F
→
01/10 12:33, , 5F
01/10 12:33, 5F