Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. # !/usr/bin/python2.7
  2. # coding=UTF-
  3.  
  4. import requests
  5. import datetime
  6. import time
  7.  
  8. listurl = open(r"url.txt", "r")
  9. log = open(r"log.txt", "w")  # a дописывать
  10.  
  11. today = datetime.datetime.today()
  12. time = today.strftime("%Y/%m/%d-%H:%M:%S")
  13. str(time)
  14. online = '(ON)'
  15. ofline = '(OFF)'
  16. data = listurl.readlines()
  17. for listurl in data:
  18.  
  19.     try:
  20.         response = requests.get(listurl)
  21.         #time.sleep(0.5)
  22.         #print(online + time + listurl)
  23.         #print('{0}{1}{2}'.format(online, time, listurl))
  24.         #log.write('{0}{1}{2}'.format(online, time, listurl))
  25.         dataon = (time+listurl+online)
  26.         log.write(str(dataon))
  27.     except requests.exceptions.RequestException:
  28.         #print('{0}{1}{2}'.format(ofline, time, listurl))
  29.         #log.write('{0}{1}{2}'.format(ofline, time, listurl))
  30.         dataoff = str(time+listurl+ofline)
  31.         log.write(str(dataoff))
  32. log.close()
  33. # listurl.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement