Question Re urllib (Jeff James)

Larry Martell larry.martell at gmail.com
Mon Dec 16 14:22:39 CET 2013


On Monday, December 16, 2013, Jeff James wrote:

> I'm not really receiving an "exception" other than those three sites, out
> of the 30 or so I have listed, are the only sites which show "is down" at
> the end of that line specifying the site.
>
>
> Where " # " has been substituted for our domain name........
>
> https://my.####.com/intranet.html* is down*
> http://#####.main.####.com/psso/pssignsso.asp?dbname=FSPRD90
> * is down *
> http://sharepoint.####.com/regions/west/PHX_NSC/default.aspx
> * is down*
>
>
>
> Cc: python-list at python.org <javascript:_e({}, 'cvml',
> 'python-list at python.org');>
> Date: Mon, 16 Dec 2013 06:54:48 -0500
> Subject: Re: Question RE urllib
> On Mon, Dec 16, 2013 at 6:40 AM, Jeff James <jeff at jeffljames.com<javascript:_e({}, 'cvml', 'jeff at jeffljames.com');>>
> wrote:
> > So I'm using the following script to check our sites to make sure they
> are
> > all up and some of them are reporting they are "down" when, in fact, they
> > are actually up.   These sites do not require a logon in order for the
> home
> > page to come up.  Could this be due to some port being blocked
> internally ?
> > Only one of the sites reporting as down is "https" but all are internal
> > sites.  Is there some other component I should be including in the
> script ?
> > There are about 30 or 40 sites that I have listed in all.  I just use
> those
> > in the following script as examples.   Thanks
> >
> > import urllib
> >
> > sites = ["http://www.amazon.com/", "
> https://internalsite.com/intranet.html",
> > etc.]
> >
> > for site in sites:
> >     try:
> >         urllib.urlopen(site)
> >         print site + " "
> >     except Exception, e:
> >         print site + " is down"
>
> In the handler print out the exception you are getting.
>

If your exception handler is being called then you are indeed getting an
exception. Add:

print str(e)

to the handler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131216/2b331b6d/attachment.html>


More information about the Python-list mailing list