The example below reads a web page of alternating headlines and
associated stories.  If the same headline appears on a later scan
the story is ignored.  It saves elements parsed from the webpage
as an array (block) of structs (object!s).
It cannot seem to restore them cleanly when rerun later.
why? How do I get around it for now?

I have simplified the example below.

REBOL [title: "sample story fetcher" ]

stories: make block! 25
story-tmpl: make object! [
 head: none
 body: none
 topics: none
 dest: none
 fileto: none
 ]

page-parser-rules: [
 any [
 thru "headline:"
 copy headl  to "story:"
 thru "story:"
 copy story-body      [ to "headline:" | to </BODY></HTML> | to end ]
 (store-story)
 ] ]

headl: make string! 30
topic: make string! 30
story-body: make string! 300

store-story: func [ /local  sry ] [
        ; drop dupes...
        foreach st stories [
                 if st/head = headl [ return false ]
               ]

; fill in struct
        sry: make story-tmpl []
        sry/head: copy headl
        append stories sry
        ]

go: func [ /local c ] [
    if exists? %articles/stor  [ stories: load %articles/stor ]
    c: read  http://localhost/storygenerator.cgi

    parse c page-parser-rules  ; calls store-story when "headl" filled
    save %articles/stor stories
    ]

go
q


;# mailto: [EMAIL PROTECTED]

Reply via email to