Python application for notifying when tickets for new event of Slask Wroclaw basketball team appeared on this page.
The application is running as a Docker daemon with Python script in it which checks content of the page with tickets. In a loop it scraps current events for which tickets are available and compares with the previously scrapped events. If some changes occurred then SMS notification with specially prepared content is sent according to the secrets.py
file.
The goal of this application is to have an option to buy tickets with the best seats for matches. This works because the ticket URL is published later on the official fanpage and many people refresh the page manually. SMSPLANET is used for SMS notification.
- Python 3.8,
- Docker,
- Selenium.
First of all clone the repository.
Create an account here and top up your balance. In sender page create your own sender name, which will appear in the SMS as the sender.
In a root directory of the repository place an secrets.py
file with following content:
SMS_PLANET_API_URL = "https://api2.smsplanet.pl"
SEND_SMS_API = f"{SMS_PLANET_API_URL}/sms"
CUT_URL_API = f"{SMS_PLANET_API_URL}/shortUrl"
API_KEY = "YOUR-KEY"
API_KEY_PASS = "YOUR-KEY-PASSWORD"
PHONE_NUMBER = YOUR-PHONE-NUMBER
SENDER_NAME = "YOUR-SENDER-NAME"
Modify variables API_KEY
and API_KEY_PASS
with values from here. As a PHONE_NUMBER
type your own number, note that the country code is optional. As a SENDER_NAME
type your created previously name, note you should wait for acceptation from the SMSPLANET.
Some variables in constants.py
file are modifiable:
...
SCAN_PERIOD = 30 # time of sleeping in a loop
LOG_FILE = "debug.log"
DEBUG = True # set to True to avoid sending real sms
DEBUG_MESSAGE = {"messageId": "DEBUG MODE IS ON"} # this mocked response will be sent if DEBUG = True
SMS_LIMIT = 5 # maximum amount of SMS to send from SMS planet API for avoiding bankruptcy
TOTAL_SMS_SENT = 0 # for checking if limit has been exceeded
SMS_LENGTH_LIMIT = 160 # maximum SMS content length above which content will be truncated
To debug the application just set DEBUG
to True
and real SMS will not be sent.
Add execution permission to run.sh
script and run it. It will run Docker daemon which will scrap data each SCAN_PERIOD
seconds.
- - consider moving from Selenium to
urllib
+lxml
since only page source is used