Compare commits

..

No commits in common. "98884d4c29279a97f30d221b8097a7a3b2374234" and "95d481ccc9b103d2a21a77dfd26ff68bec427ef9" have entirely different histories.

2 changed files with 2 additions and 9 deletions

View File

@ -1,3 +1,2 @@
beautifulsoup4
requests
loguru

View File

@ -1,7 +1,6 @@
"""buyvm stock checker"""
import requests
from bs4 import BeautifulSoup
from loguru import logger
from config import DISCORD_WEBHOOK
@ -18,7 +17,7 @@ def send_notification(payload):
try:
requests.post(DISCORD_WEBHOOK, json=payload)
except requests.RequestException as e:
logger.error(f'error sending notification: {str(e)}')
print(f'error sending notification: {str(e)}')
def get_url(url):
@ -26,7 +25,7 @@ def get_url(url):
response = requests.get(url)
response.raise_for_status()
except requests.RequestException as e:
logger.error(f'error fetching {url}: {str(e)}')
print(f'error fetching {url}: {str(e)}')
return None
return response.text
@ -59,17 +58,12 @@ def get_packages(html):
def main():
logger.info('checking buyvm stocks')
for url in URLS:
html = get_url(url)
if not html:
continue
packages = get_packages(html)
for package in packages:
if package['qty'] > 0:
logger.info(f"{package['name']}: {package['qty']} in stock")
send_notification({
"username": "stockbot-buyvm",
"embeds": [