From 14af7bc5a20648d90e853ebba9c11723d545393b Mon Sep 17 00:00:00 2001 From: Samson Melamed Date: Sun, 18 Jan 2009 00:58:06 -0500 Subject: [PATCH] report Mozilla-compatible User-Agent --- ankiqt/ui/facteditor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index bfe7a9529..6b87d2b58 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -687,7 +687,8 @@ An error was ecountered while opening %s return def _retrieveURL(self, url, ext): - filecontents = urllib2.urlopen(url).read() + req = urllib2.Request(url, None, {'User-Agent': 'Mozilla/5.0 (compatible; Anki/%s)' % ankiqt.appVersion }) + filecontents = urllib2.urlopen(req).read() (fd, name) = tempfile.mkstemp(prefix="anki", suffix=".%s" % ext.encode("ascii")) file = os.fdopen(fd, "wb") file.write(filecontents)