diff --git a/README.md b/README.md index d90b151..2b6161b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Kimsufi/So-you-Start Avaliability Crawler ============================ -> Crawler that will notify as soon as OVH servers on Kimsufi/So-you-Start become available for purchase. +> Crawler that will notify you when Kimsufi servers (or So-you-Start, or OVH) become available for purchase. **TL;DR** @@ -17,10 +17,11 @@ About Dedicated servers on [Kimsufi](http://www.kimsufi.com) and [So you Start](http://www.soyoustart.com) have amazing prices, however they are always out of stock. This crawler will notify you as aoon as servers are available for purchase; it can send emails, show Mac OS notifications, open popup windows, or even trigger sms. Then hurry up, you have around 2 minutes to complete your order :) + Set it up --------- -_Following steps have been tested on Mac and Linux_ +**Runs on Linux and Mac with Python 2.7+ or Python 3.4+** - Clone this repo (`git clone https://github.com/MA3STR0/kimsufi-crawler.git`) or download and unpack archive - Taking `config.json.example` as a template, create a file `config.json` and correct configuration according to your preferences: diff --git a/crawler.py b/crawler.py index 4c00c57..d308ec1 100755 --- a/crawler.py +++ b/crawler.py @@ -12,7 +12,11 @@ from tornado.httpclient import AsyncHTTPClient from tornado.httpclient import HTTPError from tornado.gen import coroutine -from urllib import quote +# Python 3 imports +try: + from urllib import quote +except ImportError: + from urllib.parse import quote logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s') _logger = logging.getLogger(__name__) diff --git a/notifiers/email_notifier.py b/notifiers/email_notifier.py index cdcc23c..99a5aca 100755 --- a/notifiers/email_notifier.py +++ b/notifiers/email_notifier.py @@ -1,5 +1,6 @@ """Notifier that sends email messages through SMTP""" +import sys import logging import smtplib from email.mime.text import MIMEText @@ -18,8 +19,11 @@ def __init__(self, config): self.use_ssl = config.get('use_ssl', False) self.fromaddr = config['from_email'] # smtp user may be different from email - self.fromuser = config.get('from_user', self.fromaddr).encode('utf-8') - self.frompwd = config['from_pwd'].encode('utf-8') + self.fromuser = config.get('from_user', self.fromaddr) + self.frompwd = config['from_pwd'] + if sys.version_info[0] == 2: + self.fromuser = self.fromuser.encode('utf-8') + self.frompwd = self.frompwd.encode('utf-8') self.host = config['from_smtp_host'] self.port = config.get('from_smtp_port', 587) self.toaddr = config['to_email']