diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-05-13 23:21:53 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-05-13 23:21:53 +0200 |
commit | 19c841561fe19d657ce0305bfb70a274ea9f5a36 (patch) | |
tree | c66e92cea97da26cd23985eabbc0c8064b0f09b5 | |
parent | 0a98a3f04c35d9899f1de559481d2cf2a4d2f458 (diff) | |
parent | f0f97999ba33351e3d011e73449896b1fab0dd9f (diff) |
Merge tag 'upstream/1.7.5'
Upstream version 1.7.5
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | config_template.py | 2 | ||||
-rwxr-xr-x | mwc.py | 5 |
3 files changed, 9 insertions, 1 deletions
@@ -59,6 +59,9 @@ sites = [ * <b>user-agent</b> (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' + * <b>accept</b> (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: <a href="https://github.com/Debianguru/MailWebsiteChanges/wiki/snippets">Snippet collection</a> - please feel free to add your own definitions! diff --git a/config_template.py b/config_template.py index d7069bb..02f7579 100644 --- a/config_template.py +++ b/config_template.py @@ -14,6 +14,8 @@ sites = [ 'contentxpath': '//div', 'titleregex': '', 'contentregex': '', + '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', 'encoding': 'utf-8'}, {'shortname': 'mywebsite2', @@ -90,6 +90,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) @@ -228,7 +230,8 @@ def sendmail(receiver, subject, content, sendAsHtml, link): if config.useTLS: mailsession.ehlo() mailsession.starttls() - mailsession.login(config.smtpusername, config.smtppwd) + if config.smtpusername is not None: + mailsession.login(config.smtpusername, config.smtppwd) mailsession.sendmail(config.sender, receiver.split(','), mail.as_string()) |