Last active
October 30, 2019 23:22
-
-
Save edwindotcom/d1e3c6b8731311e3c8559cb818723f93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage - run: | |
# python getTitle.py URL | |
from urllib2 import urlopen | |
import sched, time | |
from time import gmtime, strftime | |
import lxml.html | |
import sys | |
url = sys.argv[1] | |
print url | |
s = sched.scheduler(time.time, time.sleep) | |
count = 0 | |
def check_title(arg): | |
global count | |
tree = lxml.html.parse(urlopen(url+"?"+str(count))) | |
pi = tree.xpath("//title")[0] | |
now = strftime("%Y-%m-%d %H:%M:%S", gmtime()) | |
print (now + " : " + pi.text) | |
count += 1 | |
s.enter(2, 1, check_title, (arg,)) | |
s.enter(2, 1, check_title, (s,)) | |
s.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment