fix: handle 'temporarily sold out'

parent 2e036746
...@@ -3,6 +3,15 @@ ...@@ -3,6 +3,15 @@
import requests import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
blacklist = [
"Out of stock",
"temporarily sold out"
]
def in_stock(stock: str):
return not any([b in stock for b in blacklist])
def main(): def main():
url = "https://onlinebabyplants.com/shop/exclusive-alocasia-zebrina-variegated/" url = "https://onlinebabyplants.com/shop/exclusive-alocasia-zebrina-variegated/"
...@@ -13,7 +22,7 @@ def main(): ...@@ -13,7 +22,7 @@ def main():
price = soup.find(attrs={"class": "woocommerce-Price-amount amount"}).text price = soup.find(attrs={"class": "woocommerce-Price-amount amount"}).text
stock = soup.find(attrs={"class": "stock"}).text stock = soup.find(attrs={"class": "stock"}).text
if "Out of stock" not in stock: if in_stock(stock):
sms("%s en stock pour %s: \"%s\"\n-> %s" % (name, price, stock, url)) sms("%s en stock pour %s: \"%s\"\n-> %s" % (name, price, stock, url))
else: else:
print("%s pas en stock..." % name) print("%s pas en stock..." % name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment