mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +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:
parent
3ced1503ee
commit
cfcb876bc1
@ -60,6 +60,7 @@ footer_text = ''
|
|||||||
counter = 0
|
counter = 0
|
||||||
errors = 0
|
errors = 0
|
||||||
conn = None
|
conn = None
|
||||||
|
headers = {"User-Agent": "mw2html.py/Audacity"}
|
||||||
domain = ''
|
domain = ''
|
||||||
|
|
||||||
MONOBOOK_SKIN = 'monobook' # Constant identifier for Monobook.
|
MONOBOOK_SKIN = 'monobook' # Constant identifier for Monobook.
|
||||||
@ -517,7 +518,7 @@ def split_section(url):
|
|||||||
|
|
||||||
def url_open(url):
|
def url_open(url):
|
||||||
# download a file and retrieve its content and mimetype
|
# 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 = []
|
l_redir = []
|
||||||
redirect = url
|
redirect = url
|
||||||
@ -547,7 +548,7 @@ def url_open(url):
|
|||||||
#increment httplib requests counter
|
#increment httplib requests counter
|
||||||
counter += 1
|
counter += 1
|
||||||
try:
|
try:
|
||||||
conn.request("GET", rel_url)
|
conn.request("GET", rel_url,headers=headers)
|
||||||
r = conn.getresponse()
|
r = conn.getresponse()
|
||||||
print 'Status', r.status, r.reason, 'accessing', rel_url
|
print 'Status', r.status, r.reason, 'accessing', rel_url
|
||||||
if r.status == 404:
|
if r.status == 404:
|
||||||
@ -898,7 +899,7 @@ def run(out=sys.stdout):
|
|||||||
"""
|
"""
|
||||||
Code interface.
|
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'):
|
if urlparse.urlparse(config.rooturl)[1].lower().endswith('wikipedia.org'):
|
||||||
out.write('Please do not use robots with the Wikipedia site.\n')
|
out.write('Please do not use robots with the Wikipedia site.\n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user