Skip to content

Instantly share code, notes, and snippets.

@kyleterry
Created September 6, 2013 23:01
Show Gist options
  • Save kyleterry/6471148 to your computer and use it in GitHub Desktop.
Save kyleterry/6471148 to your computer and use it in GitHub Desktop.
if settings.POST_URL_TITLES:
head = requests.head(url)
content_type = head.headers['content-type'].split(' ')[0].strip(';')
if content_type == 'text/html':
request = requests.get(url)
soup = BeautifulSoup(request.text)
parser = HTMLParser()
title = soup.title.string
title = parser.unescape(title)
self.send('Link title: %s' % title, data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment