1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-29 23:19:28 +02:00

Buanzo's fix to include a User-Agent HTTP request header

This means that we don't get 403 error when dumping the Manual with the server's security features in place.
This commit is contained in:
Gale Andrews 2016-04-04 18:29:06 +01:00
parent 3ced1503ee
commit cfcb876bc1

View File

@ -60,6 +60,7 @@ footer_text = ''
counter = 0
errors = 0
conn = None
headers = {"User-Agent": "mw2html.py/Audacity"}
domain = ''
MONOBOOK_SKIN = 'monobook' # Constant identifier for Monobook.
@ -517,7 +518,7 @@ def split_section(url):
def url_open(url):
# download a file and retrieve its content and mimetype
global conn, domain, counter, redir_cache, errors
global conn, domain, counter, redir_cache, errors, headers
l_redir = []
redirect = url
@ -547,7 +548,7 @@ def url_open(url):
#increment httplib requests counter
counter += 1
try:
conn.request("GET", rel_url)
conn.request("GET", rel_url,headers=headers)
r = conn.getresponse()
print 'Status', r.status, r.reason, 'accessing', rel_url
if r.status == 404:
@ -898,7 +899,7 @@ def run(out=sys.stdout):
"""
Code interface.
"""
global conn, domain, counter, redir_cache, config
global conn, domain, counter, redir_cache, config, headers
if urlparse.urlparse(config.rooturl)[1].lower().endswith('wikipedia.org'):
out.write('Please do not use robots with the Wikipedia site.\n')