Advertisement
jackox

actualizar.py

Jun 20th, 2024 (edited)
800
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #ItemAlert v4
  2. #actualizar.py
  3.  
  4. import configparser
  5. import re
  6. import urllib.request
  7. import subprocess
  8.  
  9. config = configparser.ConfigParser()
  10. config.read('config.ini')
  11. midispositivo = config['DISPOSITIVO']['ID']
  12. url = config['GSHEET']['URL']
  13.  
  14. with urllib.request.urlopen(url) as response:
  15.    html = response.read().decode('utf-8')
  16.  
  17. regex = r"---.*?--(.*?)--.*?---"
  18. r1 = re.findall(regex, html)
  19. adispositivo = r1[0]
  20. aactualizar = r1[1]
  21. aurl = r1[2]
  22.  
  23. print (adispositivo)
  24. print (aactualizar)
  25. print (aurl)
  26.  
  27. if (aactualizar == 'SI'):
  28.     with urllib.request.urlopen(aurl) as response:
  29.         codigo = response.read()
  30.     with open("itemalert.py", "wb") as f:
  31.         f.write(codigo)
  32.         f.close()
  33. subprocess.call("itemalert.py", shell=True)
  34. #exec(open("itemalert.py").read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement