Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !/usr/bin/python2.7
- # coding=UTF-
- import requests
- import datetime
- import time
- listurl = open(r"url.txt", "r")
- log = open(r"log.txt", "w") # a дописывать
- today = datetime.datetime.today()
- time = today.strftime("%Y/%m/%d-%H:%M:%S")
- str(time)
- online = '(ON)'
- ofline = '(OFF)'
- data = listurl.readlines()
- for listurl in data:
- try:
- response = requests.get(listurl)
- #time.sleep(0.5)
- #print(online + time + listurl)
- #print('{0}{1}{2}'.format(online, time, listurl))
- #log.write('{0}{1}{2}'.format(online, time, listurl))
- dataon = (time+listurl+online)
- log.write(str(dataon))
- except requests.exceptions.RequestException:
- #print('{0}{1}{2}'.format(ofline, time, listurl))
- #log.write('{0}{1}{2}'.format(ofline, time, listurl))
- dataoff = str(time+listurl+ofline)
- log.write(str(dataoff))
- log.close()
- # listurl.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement