For simple error checking (not necessarily that the link wasn't found):

if error? try [site: read web-page][print "Error: page not found"]

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 08, 2000 2:16 PM
To: [EMAIL PROTECTED]
Subject: [REBOL] Detecting a broken Link (Server 404 not found)


Hi

My script now follows all links on a page. Yeah.

tags: make block! 200
text: make string! 8000
html-code: [
    copy tag ["<" thru ">"] (append tags tag) |
    copy txt to "<" (append text txt)
]
course: %PES102_02.htm
coursenew: join %proc/ course
page: read course
parse page [to "<" some html-code]
foreach tag tags [
    if parse tag ["<A" thru "HREF="
        [{"} copy link to {"} | copy link to ">"]
        to end
    ]
[
web-page: to url! link
site: read web-page
if find site "Error" [write/append coursenew reduce [newline link]]
]
]

I'm trying to make a simple link validator - that will write all broken
links that contain (Server 404 response) to a file. But I can't seem to
detect this. My script stops when i reach a broken link with an error
message

User Error: Target URL could not be retrieved. Server response Http/1.1 404
Not found.

The error page of the server contains the word error - so i thought i could
just see if the page contained that as a string, but my script just stops
when the first broken link is found.

How do I trap this and instead of Rebol producing an error message just
write the invalid url to a file.

Many thanks.

Aneesha

Reply via email to