推 iwfmf: 解決了 感謝您!! 看來是我原本處理over18的寫錯 05/11 10:52
https://www.ptt.cc/bbs/Gossiping/index20865.html'
html <- getURL(url, curl=curl)
這樣應該就沒問題了
※ 引述《iwfmf (i @#$%@#$^$%^ f)》之銘言:
: : 再用R爬蟲抓取八卦版,但在getURL 時,抓取的資料為空
: [程式範例]:
:
: > url
: [1] "https://www.ptt.cc/bbs/Gossiping/index20865.html"
: > html = getURL(url,ssl.verifypeer = FALSE,encoding="UTF-8")
: > html
: [1] ""
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 104.155.222.243
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1494417036.A.7D9.html
因為你沒處理 over18 的 cookie
library(RCurl)
curl <- getCurlHandle()
curlSetOpt(cookie="over18=1", followlocation = TRUE, curl=curl)
url <- '