summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--config_template.py2
-rwxr-xr-xmwc.py5
3 files changed, 9 insertions, 1 deletions
diff --git a/README.md b/README.md
index 6c6d731..d008527 100644
--- a/README.md
+++ b/README.md
@@ -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',
diff --git a/mwc.py b/mwc.py
index 606f504..a0635a1 100755
--- a/mwc.py
+++ b/mwc.py
@@ -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())