download all mib files from a web page
powah
wong_powah at yahoo.ca
Thu May 28 14:55:35 EDT 2009
On May 27, 3:37 pm, Scott David Daniels <Scott.Dani... at Acm.Org> wrote:
> powah wrote:
> > ...
> > I fixed one error, now if the filename is misspelled, how to ignore
> > the error and continue?
>
> You really should go through the tutorial. It will explain this and
> other important things well. But, since I'm feeling generous:
>
> Replace this:> u=urllib2.urlopen(link)
> > p=u.read()
> > open(filename,"w").write(p)
>
> with this:
> try:
> u = urllib2.urlopen(link)
> p = u.read()
> except urllib2.HTTPError:
> pass
> else:
> dest = open(filename, "w")
> dest.write(p)
> dest.close()
>
> --Scott David Daniels
> Scott.Dani... at Acm.Org
Thanks!
More information about the Python-list
mailing list