Compare commits
1 commit
master
...
contenttyp
| Author | SHA1 | Date | |
|---|---|---|---|
| eb3c2fc398 |
1 changed files with 5 additions and 2 deletions
|
|
@ -68,8 +68,11 @@ class Url(Model):
|
|||
if title is None:
|
||||
r = requests.get(url)
|
||||
if r.status_code == 200:
|
||||
dom = BeautifulSoup(r.content, 'html.parser')
|
||||
self.title = dom.title.string
|
||||
if 'text/html' in r.headers['content-type']:
|
||||
dom = BeautifulSoup(r.content, 'html.parser')
|
||||
self.title = dom.title.string
|
||||
else:
|
||||
self.title = r.headers['content-type']
|
||||
else:
|
||||
self.title = "Error: HTTP %s" % r.status_code
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue