[REBOL] Re: How do use 'request-download'? Or difference between Windows and Lin
From: bpaddock:csonline at: 26-Oct-2001 19:15
> Since the "?" is the offending character for the windows file system,
> replace it with something acceptable.
I was unclear I guess.
Those characters are part of the URL as they should be, but under the Windows
version of Rebol/View request-download appendeds them to the file name, under
Linux it does not, and it should not be doing it under Windows.
I think I finally hacked, since any real documentation is lacking, my way
around the problem.
Here is the exact problem:
There are 7 pages to this Patent, downloading now:
URL:
http://l2.espacenet.com/dips/bns.pdf?&PN=US4215330&ID=US+++4215330A1+I+&PG=1
FileName:
%US4215330pg1.pdf
What Windows View tries to save to disk:
** Access Error: Cannot open
/C/Rebol/public/l2.espacenet.com/dips/bns.pdf?&PN=US4215330&ID=U
S+++4215330A1+I+&PG=1
** Where: read-thru
** Near: write/binary file data
There is NO such thing as /C/Rebol/public/l2...... nor should there be but
the Windows Rebol/View tries to make it that way.
Watch for line wrap:
This is the bad code that seems to not be portable (should bad code be
portable ;-) ):
GetPageURL: probe to-url rejoin ["http://" pdf-url to-string
CurrentPageNumber]
OutputNameFILE: probe to-file rejoin ["US" PatentNumber "pg"
CurrentPageNumber ".pdf"]
; Don't get pages that we do not need:
if not exists? OutputNameFILE [
either data: load request-download GetPageURL [
write/binary OutputNameFILE data
][
alert "Download failed or canceled." quit
]
]
This seems to work in both places
; Don't get pages that we do not need:
if not exists? OutputNameFILE [
local-file: OutputNameFILE
either data: request-download/to GetPageURL
local-file [
; write/binary OutputNameFILE data
][
alert "Download failed or canceled." quit
]
]
Is there a better way?
If some one wants to take on a REAL Rebol challenge try to figure out how to
make Rebol download patents from espacenet. The URL encodings are bazaar,
and undocumented as far as I can tell so far. So far all my script does is
US patents in class A1. Got to start some place...