working
This commit is contained in:
2
.env_sample
Normal file
2
.env_sample
Normal file
@@ -0,0 +1,2 @@
|
||||
TWILIO_ACCOUNT_SID=''
|
||||
TWILIO_AUTH_TOKEN=''
|
||||
165
.gitignore
vendored
Normal file
165
.gitignore
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/python,vscode,venv
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=python,vscode,venv
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
pytestdebug.log
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
doc/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
pythonenv*
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# profiling data
|
||||
.prof
|
||||
|
||||
### venv ###
|
||||
# Virtualenv
|
||||
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
|
||||
[Bb]in
|
||||
[Ii]nclude
|
||||
[Ll]ib
|
||||
[Ll]ib64
|
||||
[Ll]ocal
|
||||
[Ss]cripts
|
||||
pyvenv.cfg
|
||||
pip-selfcheck.json
|
||||
|
||||
### vscode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/python,vscode,venv
|
||||
4
.vscode/settings.json
vendored
Normal file
4
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"python.pythonPath": "bin/python3",
|
||||
"python.envFile": "${workspaceFolder}/.env"
|
||||
}
|
||||
46
scrape.py
Normal file
46
scrape.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import requests
|
||||
from twilio.rest import Client
|
||||
import os
|
||||
from sys import exit
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv(verbose=True)
|
||||
|
||||
api_url = 'https://www.boden.co.uk/api/stock/v1/styles?market=UK&language=en-gb&id=y1357'
|
||||
website_url = 'https://www.boden.co.uk/en-gb/rainbow-3-in-1-printed-jacket/sty-y1357'
|
||||
# 40263447 low stock
|
||||
# 40263442 12-18m
|
||||
item_id = '40263442'
|
||||
message_sent_file = './sent.txt'
|
||||
|
||||
|
||||
if os.path.isfile(message_sent_file):
|
||||
print("We have already sent SMS")
|
||||
exit()
|
||||
|
||||
r = requests.get(api_url)
|
||||
j = r.json()
|
||||
|
||||
for id in j['Y1357']:
|
||||
if id['edp'] == item_id:
|
||||
if id['stockStatus'] == 'OutOfStock':
|
||||
print(f"Item is out of stock")
|
||||
else:
|
||||
print(f"Item is in stock")
|
||||
Path(message_sent_file).touch()
|
||||
# Your Account Sid and Auth Token from twilio.com/console
|
||||
# and set the environment variables. See http://twil.io/secure
|
||||
account_sid = os.environ['TWILIO_ACCOUNT_SID']
|
||||
auth_token = os.environ['TWILIO_AUTH_TOKEN']
|
||||
client = Client(account_sid, auth_token)
|
||||
|
||||
client = Client(account_sid, auth_token)
|
||||
|
||||
message = client.messages.create(
|
||||
messaging_service_sid='MG18978bd18247c16cc39d743251106813',
|
||||
body='The coat is in stock at ' + website_url,
|
||||
to='+447557447469'
|
||||
)
|
||||
|
||||
print(message.sid)
|
||||
Reference in New Issue
Block a user