Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Downloading webpage content.
Pages: [1] Print
Author Topic: Downloading webpage content.  (Read 348 times)
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
Downloading webpage content.
« on: July 04, 2005, 03:57:51 AM »

I was playing with this...

Quote
REBOL []

block: []

if not exists? %graphics/ [make-dir %graphics/]
change-dir %graphics/

prin "(Remember to add a / at the end!) ENTER ADDRESS: " get-address: to-url input

page: read get-address

parse page [
    any [thru {src="}
    copy temp to {"}
    (append block temp)] to end]

foreach graphic block [
    write/binary to-file graphic read/binary graphic
]

Which is meant to download (mostly) pictures.
But I get...

Quote
** Script Error: read expected source argument of type: file url
object block
** Near: write/binary to-file graphic read/binary graphic

I examined the block which seemed to contain valid URLs.
What's going wrong?
Thanks,
L.
 
Logged

CarlRead
Full Member
***
Offline Offline

Posts: 105


View Profile
Downloading webpage content.
« Reply #1 on: July 04, 2005, 04:13:07 AM »

Are they strings in BLOCK?  If so, add a TO-URL to convert them before you try to read them.

Hope that helps.
Logged

- Carl Read
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
Downloading webpage content.
« Reply #2 on: July 07, 2005, 03:24:41 AM »

I was trying to use to-url with the block of strings like so...

Code:
to-url block

... which gave me a merger of the whole block so I tried a FOREACH LOOP...

Code:
foreach i block [to-url i]

...which didn't work.
I'm guessing to-url would work best somewhere in the PARSE PAGE expression, but my efforts to stick it in somewhere returned nothing or a syntax error.  
Logged

aRebol
Newbie
*
Offline Offline

Posts: 4


View Profile
Downloading webpage content.
« Reply #3 on: July 10, 2005, 10:08:20 AM »

REBOL []

block: []

if not exists? %graphics/ [make-dir %graphics/]
change-dir %graphics/

prin "(Remember to add a / at the end!) ENTER ADDRESS: " get-address: input

page: read to-url get-address

parse page [
    any [thru {src="}
    copy temp to {"}
    (append block temp)] to end]

foreach graphic block [
   either find/part graphic "http://" 7 [
      url: rejoin ["/" graphic]
   ][
      url: rejoin [get-address "/" graphic]
   ]
   loop 2 [replace/all url "//" "/"]
   replace url ":/" "://"
   url: to-url url
   set [path file] split-path url
    write/binary file read/binary url
]
 
Logged
leke
Jr. Member
**
Offline Offline

Posts: 92


View Profile WWW
Downloading webpage content.
« Reply #4 on: July 11, 2005, 02:01:41 AM »

Wow Thanks! I will enjoy studying that.

I had worked on this over the weekend to solve my to-url problem...

Code:
block: ["http://a1.com" "http://b2.com" "http://c3.com" ]

block2: make block! []
foreach v block [
repend block2 (to-url v)]

; OR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; this one you don't need to define another block
foreach v block [
replace block v (to-url v)]

Logged

Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Downloading webpage content.
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 21, 2008, 12:49:48 AM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2287 Posts in 593 Topics by 3734 Members
Latest Member: aroteaFreedforeyone

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc