[Tutor] fetching wikipedia articles

Andre Engels andreengels at gmail.com
Fri Jan 23 11:37:53 CET 2009

On Fri, Jan 23, 2009 at 11:25 AM, Andre Engels <andreengels at gmail.com> wrote:

> In the __init__ of the class URLopener, add the following at the end:
> self.addheaders = [header for header in self.addheaders if header[0]
> != "User-Agent"] + [('User-Agent', '<whatever>')]
> (probably
> self.addheaders = [('User-Agent', '<whatever>')]
> does the same, but my version is more secure)

Looking further I found that a 'cleaner' way to make the same change
is to add to the code of URLopener (outside any method):

version = '<whatever>'

André Engels, andreengels at gmail.com

More information about the Tutor mailing list