Created
June 12, 2024 12:06
-
-
Save nyokinyoki/e30ada9dc5bf2a98f984171ae816ad30 to your computer and use it in GitHub Desktop.
Preverja ceno artikla na tosama.si in obvesti na discord kanal, ko cena pade.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
from bs4 import BeautifulSoup | |
URL = 'https://www.tosamashop.si/165_Dojencek-in-mamica/previjanje/i_11080_to-to-biorazgradljive-soft-krpice-60-kos' | |
regular_price = '5.29' | |
# Zamenjaj naslednji dve spremenljivki | |
# https://medium.com/@diy_tech_genuis/how-to-get-your-discord-authorization-token-and-channel-id-the-simple-way-9b8802d19034 | |
discord_channel_url = 'https://discord.com/api/v9/channels/<redacted>/messages' | |
discord_auth_token = '<redacted>' | |
headers = {"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0'} | |
page = requests.get(URL, headers=headers) | |
soup = BeautifulSoup(page.content, 'html.parser') | |
discord_headers = { | |
"Authorization": discord_auth_token | |
} | |
price_container = soup.find('div', attrs={"class": "price-container", "itemprop": "price"}) | |
price = price_container['content'] | |
if price < regular_price: | |
payload = { | |
"content": "Yay! Price is lower than {}, discounted price is {}. {}".format(regular_price, price, URL) | |
} | |
send_result = requests.post(discord_channel_url, payload, headers=discord_headers) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment