import sys, re pat = r'<title>(.*?)</title>' data = open(sys.argv[1]).read() m = re.search(pat,data) if m: print m.group(1)