Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

How do use 'request-download'? Or difference between Windows and Lin

 [1/4] from: allenk:powerup:au at: 27-Oct-2001 7:27


Hi Bob, Since the "?" is the offending character for the windows file system, replace it with something acceptable. replace outputnamefile "?" "-" ==%file-name.txt or if you want to remove all illegal chars for the windows system from a filename (no replacement) outputfilename: outputfilename: %"this*would<scare|the?file:system.txt" trim/with outputfilename {/\:*?"<>|} %thiswouldscarethefilesystem.txt Cheers, Allen K

 [2/4] 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...

 [3/4] from: asindle::webmail::co::za at: 28-Oct-2001 13:45


If you find something that works in windows, pls send me the script. Thanks ----- Original Message ----- From: Bob Paddock <[bpaddock--csonline--net]> To: <[rebol-list--rebol--com]> Sent: Saturday, October 27, 2001 1:15 AM Subject: [REBOL] Re: How do use 'request-download'? Or difference between Windows and Linux??

 [4/4] from: bpaddock:csonline at: 28-Oct-2001 8:42


On Sunday 28 October 2001 06:45 am, [asindle--webmail--co--za] wrote:
> If you find something that works in windows, pls send me the script.
It is attached. If any one has a better way to do this I'd like to know it. -- Attached file included as plaintext by Listar -- -- File: patent.r REBOL [ Title: "Get Patent" Date: 26-Oct-2001/17:56:00:00-4:00 File: %patent.r Author: "Bob Paddock" Version: 1.0.3 ] ; This needs a LOT of work in the patent encodeing section. :-( GetPatent: func [ {Request a Patent Number to download from the net. Show progress. Return none on error.} PatentNumber /local url page pdf-url LastPage CurrentPage GetPageURL OutputNameFILE stop PatentDownload ] [ ;Examples PatentNumber: 4215330, 6163242 ;http://l2.espacenet.com/dips/bnsviewnav?CY=ep&LG=en&DB=EPD&PN=US6163242&ID=US+++6163242A1+I+ ;http://l2.espacenet.com/dips/bnsviewnav?CY=gb&LG=en&DB=EPD&PN=US4215330&ID=US+++4215330A1+I+ ; Read the 'navbar' to find out how many pages that there are to download: url: to-url rejoin ["http://l2.espacenet.com/dips/bnsviewnav?DB=EPD&PN=US" PatentNumber "&ID=US+++" PatentNumber "A1+I+"] page: read url ; Uncomment the following to see what the page we just got looks like: ; print page not-now1: "Service is temporarily unavailable" if find page not-now1 [alert not-now1 quit] not-now2: "The document request could not be processed" if find page not-now2 [alert not-now2 quit] ; Copy 10 chars after "TOPPG=" to find the number of pages in this patent LastPage: to-integer second parse copy/part find page "TOTPG=" 10 "=&" ;LastPage: 3 ; testing if LastPage < 1 [alert "Zero Pages to This Patent?" quit] print rejoin ["There are " LastPage " pages to this Patent, downloading now:"] pdf-url: rejoin ["l2.espacenet.com/dips/bns.pdf?&PN=US" PatentNumber "&ID=US+++" PatentNumber "A1+I+&PG="] ; Download all of the pages in the following loop, ; printout the URL and the name of the file being saved as we go: view/new center-face PatentDownload: layout [ title: text 300 bold red black center ProgressBar: progress 300x30 across toggle 90 "Cancel" "Stop" [stop: true] stat: text 240 bold red black middle return ElapsedTimeText: text 240 bold red black center return EstimatedTimeText: text 240 bold red black center return RemainingTimeText: text 240 bold red black center ] stop: false ProgressBar/data: 0 title/text: reform ["Patent " PatentNumber " has " LastPage "pages"] show title StartTime: now/time ElapsedTimeText/text: reform ["Start Time: " StartTime] show ElapsedTimeText repeat CurrentPageNumber LastPage [ wait 1 ; Required to get the 'cancle' button to work if stop [break] stat/text: reform ["Downloading Page " CurrentPageNumber " Now"] show stat 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 [ local-file: OutputNameFILE either data: request-download/to GetPageURL local-file [ ;write/binary OutputNameFILE data ][ alert "Download failed or canceled." quit ] ] ProgressBar/data: ProgressBar/data + (1 / LastPage) elapsed: now/time - StartTime estimated: elapsed * ((LastPage + 1) / CurrentPageNumber) ElapsedTimeText/text: reform ["Elapsed Time: " elapsed] EstimatedTimeText/text: reform ["Estimated Time: " estimated] RemainingTimeText/text: reform ["Remaining Time: " estimated - elapsed] show [stat ProgressBar ElapsedTimeText EstimatedTimeText RemainingTimeText] ] ; Repeat unview/only PatentDownload print "Leaving GetPatent" ] ; GetPatent ; Derived from emailsend.r: view layout [ backdrop 30.40.100 effect [grid 10x10] origin 40x20 h2 white "Select Patent Server:" ; rotary "Red" "Green" "Blue" "Yellow" server: choice "Server 1" "Server 2" "Server 3" "Server4" ; text-list "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" ; server: rotary "Server 1" "Server 2" "Server 3" "Server4" [effect pick [ ; "Server1" "Server 2" "Server 3" "Server 4"] index? server/data server/data <> 1] ;do print server h2 white "Download Patent:" msg: field "Enter Patent Number here..." 210 text white "By Your Command:" across return button "Get Patent" [GetPatent msg/text] return button "Quit" [quit] ] do-events