Compare commits
No commits in common. "b4a27df6b1b63e5be922ee39dbca8f54cf1e3f51" and "95d481ccc9b103d2a21a77dfd26ff68bec427ef9" have entirely different histories.
b4a27df6b1
...
95d481ccc9
@ -1,3 +1,2 @@
|
|||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
requests
|
requests
|
||||||
loguru
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""buyvm stock checker"""
|
"""buyvm stock checker"""
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from config import DISCORD_WEBHOOK
|
from config import DISCORD_WEBHOOK
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ def send_notification(payload):
|
|||||||
try:
|
try:
|
||||||
requests.post(DISCORD_WEBHOOK, json=payload)
|
requests.post(DISCORD_WEBHOOK, json=payload)
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
logger.error(f'error sending notification: {str(e)}')
|
print(f'error sending notification: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
def get_url(url):
|
def get_url(url):
|
||||||
@ -26,7 +25,7 @@ def get_url(url):
|
|||||||
response = requests.get(url)
|
response = requests.get(url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
logger.error(f'error fetching {url}: {str(e)}')
|
print(f'error fetching {url}: {str(e)}')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return response.text
|
return response.text
|
||||||
@ -59,17 +58,12 @@ def get_packages(html):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logger.info('checking buyvm stocks')
|
|
||||||
for url in URLS:
|
for url in URLS:
|
||||||
html = get_url(url)
|
html = get_url(url)
|
||||||
|
|
||||||
if not html:
|
|
||||||
continue
|
|
||||||
|
|
||||||
packages = get_packages(html)
|
packages = get_packages(html)
|
||||||
for package in packages:
|
for package in packages:
|
||||||
if package['qty'] > 0:
|
if package['qty'] > 0:
|
||||||
logger.info(f"{package['name']}: {package['qty']} in stock")
|
|
||||||
send_notification({
|
send_notification({
|
||||||
"username": "stockbot-buyvm",
|
"username": "stockbot-buyvm",
|
||||||
"embeds": [
|
"embeds": [
|
||||||
|
Loading…
Reference in New Issue
Block a user