Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Object Moved" error in using the RCurl getURL function in order to access an ASP Webpage

Tags:

curl

r

I am trying to use the getURL function of RCurl Package in order to access an ASP Webpage as:

my_url <- "http://www.my_site.org/my_site/main.asp?ID=11&REFID=33"
webpage <- getURL(my_url)

but I get an Object Moved redirection error message like:

    "<head><title>Object moved</title></head>\n<body><h1>Object Moved</h1>
This object may be found <a HREF=\"/my_site/index.asp\">here</a>.</body>\n"

I followed various suggestions like using the curlEscape URL encoding function or by setting the CURLOPT_FOLLOWLOCATION and CCURLOPT_SSL_VERIFYHOST Parameters via the curlSetOpt Function as listed in the php ssl curl : object moved error link, but the later 2 were not recognized as valid RCurl options.

Any suggestions how to overcome the issue?

like image 523
user274136 Avatar asked Sep 01 '10 08:09

user274136


1 Answers

Use the followlocation curl option:

getURL(u,.opts=curlOptions(followlocation=TRUE))

with added cookiefile goodness - its supposed to be a file that doesnt exist, but I'm not sure how you can be sure of that:

w=getURL(u,.opts=curlOptions(followlocation=TRUE,cookiefile="nosuchfile"))
like image 77
Spacedman Avatar answered Nov 05 '22 10:11

Spacedman