Dear All,
I would like to download a file from the web with Stata's -copy-
command. The server that provides the data uses redirection. After
accessing a given URL1, the server issues a special code to the
browser (I presume it is 307) and the new location (URL2). This
happens automatically in the browser and no special actions from the
user are required. A typical use would be to provide a link in a form
of "www.foobar.com/recent_event" and redirect to the page that
describes the most recent event, which obviously changes with time, so
at one point redirection will be to "www.foobar.com/events/alpha.htm"
and in another to "www.foobar.com/events/beta.htm" (URL is made up).
The following happens in Stata:
. copy [URL1] [LocalFile]
file [URL1] not found
server says file temporarily redirected to [URL2]
1. The file as it is mentioned in URL2 exists, but the data provider
insists to always access URL1 and follow the redirection route
received in response to access the data (otherwise I might download an
outdated version). However I don't see a way to programmatically
access the value of URL2 (which is correctly displayed in the error
message). Is there anything that can be done to it, except logging to
a text file and then parsing it for the new URL?
2. Stata seems to recode the URL2 to lowercase, which on
case-sensitive servers completely eliminates a possibility to download
the file (my case), even if I parse the log and extract URL2 from
Stata's output. Is there a way to overcome this?
3. Perhaps there is a way to tell Stata to follow redirection
instructions received from the server?
Any suggestions are highly welcomed.
Thank you,
Sergiy Radyakin
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/