Consider this simple function RCurlto report a download progress:
library(RCurl)
curlDown=function(url, follow=TRUE){
x=getURL(url, followlocation=follow, noprogress = FALSE,
progressfunction=function(down,up) cat(down, '\n'))
}
Please note that with followlocation=TRUE(by default) we take for a possible redirect that the server sends as part of the HTTP header.
We get:
curlDown("http://www.example.com")
As you can see, the variable downpassed to the callback with RCurlis a numerical vector in which the first element is the total amount of download in bytes, and the second is the current size of the downloaded file. Due to space limitations, I don’t show it here, but on a separate inspection I saw that the first corresponds to the field Content-Lengthin the response header.
Not every server gives a field Content-Lengthin the response header:
curlDown("http://www.google.it")
RCurl ( NA ?).
Google ".com" , ".it", , (). ".it'-", :
curlDown("http://www.google.com")
. curlDown("http://www.google.it"), , , ; , !
, :
curlDown("http://www.google.com", follow=FALSE)
# 0 0
# 274 274
# 274 274
# 274 274
.com Content-Length, 274 , - (. curlDown("http://www.google.it").
, RCurl ( ), 274 .
- ?