[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
入門(寫過其他程式,只是對語法不熟悉)
[問題敘述]:
我在爬一個網頁, 但如果我爬得太快它會抓不到
因為有試過讓他常態性的休息, 但休息時間太短也不行
所以我設了一個if條件, 抓不到的時候就休息60秒
但他沒有執行 不知道是不是哪裡出了問題
[程式範例]:
if(a==-1) { Sys.sleep(60)
subdoc <- GET(suburl, config = set_cookies('JSESSIONID' =
'8F0C390B5E686300BC04AA763900EB6D'))
json <- xml_text(xml_find_all(content(subdoc), '/html/body'))
}
[環境敘述]:
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] jsonlite_1.5 httr_1.3.1 xml2_1.0.0
loaded via a namespace (and not attached):
[1] compiler_3.4.0 R6_2.2.0 tools_3.4.0 curl_2.3 Rcpp_0.12.13
[關鍵字]:
Sys.sleep, if