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

[REBOL] Re: How do use 'request-download'? Or difference between Windows and Lin

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 ; ; ; Read the 'navbar' to find out how many pages that there are to download: url: to-url rejoin ["" 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 ["" 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