Hey Gang,
    I have a few stocks that I follow and I like to keep up to date on gossip on Raging Bull.  I like Jim Goodnow's script for retrieving text from this site, but found the message counter a limitation.  I modified his script so that now it will look for a new pages on a given ticker, if none, it will quit, else it will loop through page retrieval until it encounter's an error reading, then quit.  It is a very elementary change to the script.  I thought that I would put it out to the group, since it is a little different.  I like it, because now I just fire up all of my RB retrieval scripts and go surfing to other pages while I wait for the scripts to download all of the messages it encounters.  I can then read them later at my own leisure.

REBOL[

    Title: "Raging Bull page downloader"

    Author: "Jim Goodnow II"

    Date: 16-Sep-1999

    File: %raging-bull.r

    Purpose: {

    This script reads sequential pages from the

    Raging-Bull on-line bulletin board.

}

    Note: {

    It parses the HTML page looking for the author and

    the text of the message. It then appends that

    information to an HTML page that is created. The idea

    is to allow much quicker scanning of the new posts to

    the bulletin board without having to hit click on the

    NEXT button and wait for each page to load. The last

    number read is saved in a text file that is loaded

    before reading pages and then written at the end.

}

]

secure none

    ; load the next message number to read

    ; if not found, start at one

    either error? start: try [ load %AMZN.txt ][

    start: 1] []

    ; modify the AMZN below to the particular stock board you are interested in

    addr: http://www.ragingbull.com/mboard/boards.cgi?board=AMZN&read=

    f: open/new %AMZN.html ; this is where the output will go

    append f "<html><body>^/"

    whos: copy []

    txts: copy []

    ;Priming read of web page before while loop

    a: rejoin [ addr start ]

    print [ "reading" a ]

    ; on error?, close f and quit application

    if error? try [ page: read a ]

                  [append f "</body></html>^/"

                   close f

                   quit]

    while [ true ] [

        ; or if the parse fails, stop in case it's a page not found result

        ; So, the following skips over all the HTML till the ">By:" is found.

        ; Skips to the next HTML tag, copys the name to the WHO variable.

        ; Then it skips to the next TABLE tag and copys thru the end of the

        ; table to the TXT variable. Then it skips to the end.

        if not parse page [to ">By:" to "<" "<" thru ">" copy who to "<"

        to "<TABLE" copy txt thru "/TABLE>"

        to end ][ break ]

        ; display the message number followed by the author, followed by the

        ; message itself

        append f reduce [ start " By: " who "<BR>" txt "<BR>" ]

        ; increment the message counter

        start: start + 1

        ;look for next incremental web post

        a: rejoin [ addr start ]

        print [ "reading" a ]

        ; if we get an error reading, break out of loop

        if error? try [ page: read a ][ break ]

]

; save the new starting message number

save %AMZN.txt start

; close out the document

append f "</body></html>^/"

close f

quit

Eddie Newton

 

Reply via email to