Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
title_finder.py
#!/usr/bin/python
# Source: http://ubuntuforums.org/showthread.php?t=1215158
import urllib2
import sys
from BeautifulSoup import BeautifulSoup
file = sys.argv[1]
# assumes file is a list of valid URLs, one URL per line
for entry in open(file):
try:
URLObject = urllib2.urlopen(entry)
html = BeautifulSoup(URLObject.read())
data = html.find('title')
print data.contents[0].strip()
print entry
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment