Description: Add Header User-agent and Accept Author: Jörg Frings-Fürst Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862004 Forwarded: https://github.com/Debianguru/MailWebsiteChanges/issues/11 Last-Update: 2017-05-07 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ Index: trunk/mwc.py =================================================================== --- trunk.orig/mwc.py +++ trunk/mwc.py @@ -68,6 +68,8 @@ def parseSite(site): contenttype = site.get('type', 'html') contentregex = site.get('contentregex', '') titleregex = site.get('titleregex', '') + UserAgent = site.get('User-agent', '') + Accept = site.get('Accept', '') enc = site.get('encoding', defaultEncoding) contentxpath = site.get('contentxpath', '') @@ -86,7 +88,12 @@ def parseSite(site): file = process.stdout else: # open website - file = urllib.request.urlopen(uri) + req = urllib.request.Request(uri) + if UserAgent != '': + req.add_header('User-agent', UserAgent) + if Accept != '': + req.add_header('Accept', Accept) + file = urllib.request.urlopen(req) if contenttype == 'text' or (contentxpath == '' and titlexpath == ''):