Getting HTTP responses - a python linkchecking script.



Hi Folks,

I'm thinking about writing a script that can be run over a whole site
and produce a report about broken links etc...

I've been playing with the urllib2 and httplib modules as a starting
point and have found that with urllib2 it doesn't seem possible to get
HTTP status codes.

I've had more success with httplib...
Firstly I create a new HTTPConnection object with a given hostname and
port then I try connecting to the host and catch any socket errors
which I can assume mean the server is either down or doesn't exist at
this place anymore.
If the connection was successful I try requesting the resource in
question, I then get the response and check the status code.

So, I've got the tools I need to do the job sufficiently. Just
wondering whether anybody can recommend any alternatives.

Cheers,
-Blair

.



Relevant Pages

  • Re: Getting HTTP responses - a python linkchecking script.
    ... I've been playing with the urllib2 and httplib modules as a starting ... HTTP status codes. ... I've had more success with httplib... ... port then I try connecting to the host and catch any socket errors ...
    (comp.lang.python)
  • [PATCH 01/16] trivial: fix assorted "success" typos
    ... Subject: trivial: fix assorted "success" typos ... error code otherwise. ... + * called once we have a lock from a successful search ... Return codes ...
    (Linux-Kernel)
  • Re: Return value(s) from functions - any defacto standard?
    ... values that indicate success and fail. ... success, returns 0 for some calls and returns 1 on others. ... suppose if you want to mix in failure mode codes as returns from these ... report error codes some other way. ...
    (microsoft.public.vc.mfc)
  • Return value(s) from functions - any defacto standard?
    ... values that indicate success and fail. ... success, returns 0 for some calls and returns 1 on others. ... suppose if you want to mix in failure mode codes as returns from these ...
    (microsoft.public.vc.mfc)
  • Re: Need help desperately!
    ... In your Save code there is only one TableUpdate() w/o a specified ... workarea and w/o checking the function's success. ... Codes in cmdNew_user: ...
    (microsoft.public.fox.helpwanted)