Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- import requests
- from bs4 import BeautifulSoup
- from loguru import logger
- API_KEY = "0000000000000000000000000000000000000000"
- CHAT_ID = "-0000000000000"
- async def get_price():
- URL = 'https://www.gputracker.eu/nl/search/category/1/grafische-kaarten?onlyInStock=true&fv_gpu.chip=NVIDIA%20RTX%203080'
- page = requests.get(URL)
- soup = BeautifulSoup(page.content, 'html.parser')
- results = soup.find(id='facet-search-results')
- job_elems = results.find_all('div', class_='font-weight-bold text-secondary w-100 d-block h1 mb-2')
- prices = []
- for job_elem in job_elems:
- price = str(job_elem.find('span'))
- price = price[6:-7]
- prices.append(int(price))
- if prices:
- return min(prices)
- else:
- return 9999
- async def main():
- while True:
- price = await get_price()
- logger.info("Lowest current price: "+ str(price))
- target = 850
- if price < target:
- logger.info("Sending message")
- s = "3080 price dropped below "+str(target)+"EUR. It is available for " + str(price) + "!"
- s.replace(" ", "%20")
- url = "https://api.telegram.org/bot"+ API_KEY + "/sendMessage?chat_id=" + CHAT_ID + "&text="
- msg = url + s
- ret = requests.get(msg)
- link = url + 'https://www.gputracker.eu/nl/search/category/1/grafische-kaarten?onlyInStock=true&fv_gpu.chip=NVIDIA%20RTX%203080'
- retlink = requests.get(link)
- logger.info("Waiting with sending a message for 10 minutes")
- await asyncio.sleep(600)
- await asyncio.sleep(60)
- if __name__ == "__main__":
- res = asyncio.get_event_loop().run_until_complete(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement