refactor(baby): Only zebrina

parent 36ce0743
...@@ -3,22 +3,16 @@ from bs4 import BeautifulSoup ...@@ -3,22 +3,16 @@ from bs4 import BeautifulSoup
def main(): def main():
url_zebrina = "https://onlinebabyplants.com/shop/exclusive-alocasia-zebrina-variegated/" url = "https://onlinebabyplants.com/shop/exclusive-alocasia-zebrina-variegated/"
url_poinsettia = "https://onlinebabyplants.com/shop/poinsettia/"
url_dragon = "https://onlinebabyplants.com/shop/alocasia-pink-dragon/"
for url in [url_zebrina, res = requests.get(url)
url_poinsettia, soup = BeautifulSoup(res.content, "html.parser")
# url_dragon name = soup.find(attrs={"class": "product_title"}).text
]: stock = soup.find(attrs={"class": "stock"}).text
res = requests.get(url) print("%s: %s" % (name, stock))
soup = BeautifulSoup(res.content, "html.parser")
name = soup.find(attrs={"class": "product_title"}).text
stock = soup.find(attrs={"class": "stock"}).text
print("%s: %s" % (name, stock))
if "Out of stock" not in stock: if "Out of stock" not in stock:
sms("%s in stock 🎉 \"%s\"\n🔗 %s" % (name, stock, url)) sms("%s in stock 🎉 \"%s\"\n🔗 %s" % (name, stock, url))
def sms(msg: str): def sms(msg: str):
...@@ -30,7 +24,7 @@ def sms(msg: str): ...@@ -30,7 +24,7 @@ def sms(msg: str):
if res.ok: if res.ok:
print("Success!") print("Success!")
else: else:
print(res.reason, res.headers, res.) print(res.status_code, res.reason, res.headers)
if __name__ == '__main__': if __name__ == '__main__':
......
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