Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Catching HTTPErrors and URLErrors
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom  
View profile  
 More options Sep 4 2012, 12:52 pm
From: Tom <boot...@gmail.com>
Date: Tue, 4 Sep 2012 09:52:33 -0700 (PDT)
Local: Tues, Sep 4 2012 12:52 pm
Subject: Re: Catching HTTPErrors and URLErrors

Hello,
       I added both the continue's and the "soup1 = BeautifulSoup(data,
"html5lib",
from_encoding="utf-8")" into the try and except block.  I keep getting
similar errors.. Such as HttpError no defined..
Any ideas on how to get around this?

Thanks,
Tom

On Friday, August 31, 2012 6:50:25 AM UTC-4, Paul Walker wrote:

> On 30 August 2012 19:03, Tom <boo...@gmail.com <javascript:>> wrote:

> > have any suggestions for catching these, passing them by, and continuing
> on
> > with the loop?

> > for link in row.find_all('a', limit=1):
> >                 y = (link.get('href'))
> >                 time.sleep(15)
> >                 try:
> >                     data = urllib2.urlopen(y).read()
> >                 except HTTPError, e:
> >                     print "The server could not fulfill the request."
> >                     print "Error code: ", e.code
> >                     time.sleep(100)
> >                 except URLError, e:
> >                     print "We failed to reach a server."
> >                     print "Reason: ", e.reason
> >                 soup1 = BeautifulSoup(data, "html5lib",
> > from_encoding="utf-8")

> Two suggestions:

> * use a continue in the except clauses, which probably isn't necessary if
> * you move "soup1 = BeautifulSoup(data, "html5lib",
> from_encoding="utf-8")" inside the try. As it stands, it's calling
> BeautifulSoup with an empty object. It may even say that in the
> backtrace if you check it. :-)

> --
> Paul


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.