作者lovedmagic (EricZou)
看板R_Language
標題[問題] 如何將html_nodes的資料轉成CSV
時間Sun Dec 4 21:02:15 2016
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
新手(沒寫過程式,R 是我的第一次)
[問題敘述]:
參考了一下板上的資訊,對於用rvest轉CSV檔還是不瞭解
請求指點迷津
[程式範例]:
if (!"installr" %in% installed.packages()) install.packages("installr")
library(installr)
require2(rvest)
require2(stringr)
require2(pipeR)
ateam1 <- read_html("
https://www.kickstarter.com/mexico?ref=hero")
asd = html_nodes(ateam1, "ul.project-stats")
html_text(asd)
[1] "\n53% funded\n\n\nMX$ 24,235 pledged\n\n\nFunded\n\n\n\n\n\n
[2] "\n4% funded\n\n\nMX$ 7,305 pledged\n\n\nFunded\n\n\n\n\n\n
[3] "\n67% funded\n\n\nMX$ 54,050 pledged\n\n\nFunded\n\n\n\n\n\n
如果我將資料匯出成CSV有什麼辦法呢?直接用write.csv會出現他是nodes
所以不能用data.frame的方式輸出,而其實我只要53%- $24235 、4%
- $7305 這兩個資料,那我又有什麼其他的方法可以完成呢?
[環境敘述]:
Windows 7
R 3.2.2
[關鍵字]:
html、網路爬蟲
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.47.34.42
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1480856539.A.695.html
→ clansoda: html_text?? 12/04 21:09
→ clansoda: 拍謝沒看完 我以為你沒寫text 12/04 21:10