脚本“wget_test.R”:
print(paste0('OUT:', shell("bash -c 'wget https://www.ft.com -O out.html'", intern = TRUE)))
我在 R 控制台中运行:
[1] "OUT:Will not apply HSTS. The HSTS database must be a regular and non-world-writable file."
[2] "OUT:ERROR: could not open HSTS store at '/home/adollo/.wget-hsts'. HSTS will be disabled."
[3] "OUT:--2019-07-18 14:58:46-- https://www.ft.com/"
[4] "OUT:Resolving www.ft.com (www.ft.com)... 151.101.246.109"
[5] "OUT:Connecting to www.ft.com (www.ft.com)|151.101.246.109|:443... connected."
[6] "OUT:HTTP request sent, awaiting response... 200 OK"
[7] "OUT:Length: 446829 (436K) [text/html]"
[8] "OUT:Saving to: вЂ\u0098out.html’"
[9] "OUT:"
[10] "OUT: 0K .......... .......... .......... .......... .......... 11% 851K 0s"
[11] "OUT: 50K .......... .......... .......... .......... .......... 22% 1.65M 0s"
[12] "OUT: 100K .......... .......... .......... .......... .......... 34% 47.7M 0s"
[13] "OUT: 150K .......... .......... .......... .......... .......... 45% 51.5M 0s"
[14] "OUT: 200K .......... .......... .......... .......... .......... 57% 636K 0s"
[15] "OUT: 250K .......... .......... .......... .......... .......... 68% 36.9M 0s"
[16] "OUT: 300K .......... .......... .......... .......... .......... 80% 47.7M 0s"
[17] "OUT: 350K .......... .......... .......... .......... .......... 91% 51.0M 0s"
[18] "OUT: 400K .......... .......... .......... ...... 100% 47.2M=0.2s"
[19] "OUT:"
[20] "OUT:2019-07-18 14:58:46 (2.46 MB/s) - вЂ\u0098out.html’ saved [446829/446829]"
[21] "OUT:"
我在 Windows 终端中运行“RScript wget_test.R”:
Will not apply HSTS. The HSTS database must be a regular and non-world-writable file.
ERROR: could not open HSTS store at '/home/adollo/.wget-hsts'. HSTS will be disabled.
--2019-07-18 14:59:03-- https://www.ft.com/
Resolving www.ft.com (www.ft.com)... 151.101.246.109
Connecting to www.ft.com (www.ft.com)|151.101.246.109|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 446759 (436K) [text/html]
Saving to: ‘out.html’
out.html 100%[=================================================>] 436.29K --.-KB/s in 0.1s
2019-07-18 14:59:03 (3.07 MB/s) - ‘out.html’ saved [446759/446759]
[1] "OUT:"
我也试过系统功能 - 结果是一样的。
结果差异的原因可能是什么?
R 控制台中的 sessionInfo():
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.1251
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rvest_0.3.4 xml2_1.2.0
loaded via a namespace (and not attached):
[1] httr_1.4.0 compiler_3.6.0 selectr_0.4-1 magrittr_1.5 R6_2.4.0 tools_3.6.0 curl_3.3 Rcpp_1.0.1 stringi_1.4.3
[10] stringr_1.4.0
sessionInfo() 通过 RScript.exe:
R version 3.6.0 (2019-04-26) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale: [1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 [3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C [5] LC_TIME=Russian_Russia.1251
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_3.6.0