Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import requests
  2. import urllib.request
  3. import time
  4. from bs4 import BeautifulSoup
  5. import os
  6. import logging
  7.  
  8.  
  9. #make the log file
  10. logging.basicConfig(filename="newfile.log",
  11. format='%(asctime)s %(message)s',
  12. filemode='w')
  13. logger = logging.getLogger()
  14. logger.setLevel(logging.DEBUG)
  15.  
  16. #GET THE HTML
  17. try:
  18. logger.info("Getting HTML")
  19. url = 'http://plex.hrotti.net/web/index.html'
  20. response = requests.get(url)
  21. soup = BeautifulSoup(response.text, "html.parser")
  22. stringafsoup = str(soup)
  23. except:
  24. logger.exception("Failed getting html")
  25.  
  26.  
  27. #CHECK IF IT IS OK
  28. try:
  29. if "503 Service Temporarily Unavailable" in stringafsoup:
  30. logger.warning("Everything is NOT OK")
  31. except:
  32. logger.exception("WTF WE FAILED")
  33. else:
  34. logger.info("Everything is OK")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement