[问题类型]:
程式咨询(我想用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