|
Pages: [1]
|
 |
|
Author
|
Topic: Downloading webpage content. (Read 347 times)
|
|
leke
|
I was playing with this... 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... ** 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
|
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
|
I was trying to use to-url with the block of strings like so... to-url block ... which gave me a merger of the whole block so I tried a FOREACH LOOP... 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
|
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
|
Wow Thanks! I will enjoy studying that. I had worked on this over the weekend to solve my to-url problem... 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]
|
|
|
 |