From 0a98a3f04c35d9899f1de559481d2cf2a4d2f458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 13 May 2017 23:21:00 +0200 Subject: some work with patches --- debian/patches/0115-Add_header.patch | 58 +++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'debian/patches/0115-Add_header.patch') diff --git a/debian/patches/0115-Add_header.patch b/debian/patches/0115-Add_header.patch index b9fc54e..6ce0c15 100644 --- a/debian/patches/0115-Add_header.patch +++ b/debian/patches/0115-Add_header.patch @@ -1,4 +1,4 @@ -Description: Add Header User-agent and Accept +Description: Add Header 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 @@ -9,26 +9,42 @@ 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) +@@ -91,6 +91,8 @@ def parseSite(site): + req = urllib.request.Request(uri) + if 'user-agent' in site: + req.add_header('User-Agent', site['user-agent']) ++ if 'accept' in site: ++ req.add_header('Accept', site['accept']) + file = urllib.request.urlopen(req) - 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) +Index: trunk/README.md +=================================================================== +--- trunk.orig/README.md ++++ trunk/README.md +@@ -59,7 +59,9 @@ sites = [ + * user-agent (optional) + Defines the user agent string, e.g., + 'user-agent': 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0' +- ++ * accept (optional) ++ Defines the accept string, e.g., ++ 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' + + * We collect some XPath/CSS snippets at this place: Snippet collection - please feel free to add your own definitions! + +Index: trunk/config_template.py +=================================================================== +--- trunk.orig/config_template.py ++++ trunk/config_template.py +@@ -12,7 +12,9 @@ sites = [ + 'contentxpath': '//div', + 'titleregex': '', + 'contentregex': '', +- 'encoding': 'utf-8'}, ++ 'encoding': 'utf-8', ++ 'user-agent': 'Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:49.0) Gecko/20100101 Firefox/49.0', ++ 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'}, - if contenttype == 'text' or (contentxpath == '' and titlexpath == ''): + {'shortname': 'mywebsite2', + 'uri': 'http://www.mywebsite2.com/info', -- cgit v1.2.3