Commit d46341a9 authored by Jonathan Harker's avatar Jonathan Harker

URL title is content type header for non HTML responses.

parent bbcd5b22
......@@ -68,8 +68,11 @@ class Url(Model):
if title is None:
r = requests.get(url)
if r.status_code == 200:
if 'text/html' in r.headers['content-type']:
dom = BeautifulSoup(r.content, 'html.parser')
self.title = dom.title.string
self.title = r.headers['content-type']
self.title = "Error: HTTP %s" % r.status_code
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment