I_Cheer3d

Untitled

Jan 28th, 2021
732
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import asyncio
  2. import requests
  3. from bs4 import BeautifulSoup
  4. from loguru import logger
  5.  
  6. API_KEY = "0000000000000000000000000000000000000000"
  7. CHAT_ID = "-0000000000000"
  8.  
  9. async def get_price():
  10.     URL = 'https://www.gputracker.eu/nl/search/category/1/grafische-kaarten?onlyInStock=true&fv_gpu.chip=NVIDIA%20RTX%203080'
  11.     page = requests.get(URL)
  12.  
  13.     soup = BeautifulSoup(page.content, 'html.parser')
  14.     results = soup.find(id='facet-search-results')
  15.     job_elems = results.find_all('div', class_='font-weight-bold text-secondary w-100 d-block h1 mb-2')
  16.     prices = []
  17.     for job_elem in job_elems:
  18.         price = str(job_elem.find('span'))
  19.         price = price[6:-7]
  20.         prices.append(int(price))
  21.  
  22.     if prices:
  23.         return min(prices)
  24.     else:
  25.         return 9999
  26.  
  27.  
  28. async def main():
  29.     while True:
  30.         price = await get_price()
  31.         logger.info("Lowest current price: "+ str(price))
  32.         target = 850
  33.         if price < target:
  34.             logger.info("Sending message")
  35.  
  36.             s = "3080 price dropped below "+str(target)+"EUR. It is available for " + str(price) + "!"
  37.             s.replace(" ", "%20")
  38.             url = "https://api.telegram.org/bot"+ API_KEY + "/sendMessage?chat_id=" + CHAT_ID + "&text="
  39.             msg = url + s
  40.             ret = requests.get(msg)
  41.             link = url + 'https://www.gputracker.eu/nl/search/category/1/grafische-kaarten?onlyInStock=true&fv_gpu.chip=NVIDIA%20RTX%203080'
  42.             retlink = requests.get(link)
  43.             logger.info("Waiting with sending a message for 10 minutes")
  44.             await asyncio.sleep(600)
  45.         await asyncio.sleep(60)
  46.  
  47.  
  48. if __name__ == "__main__":
  49.     res = asyncio.get_event_loop().run_until_complete(main())
RAW Paste Data