diff --git a/vrobbler/apps/webpages/models.py b/vrobbler/apps/webpages/models.py
index 5442779..89b37e5 100644
--- a/vrobbler/apps/webpages/models.py
+++ b/vrobbler/apps/webpages/models.py
@@ -161,9 +161,11 @@ class WebPage(ScrobblableMixin):
if not raw_text:
return
- self.title = raw_text[raw_text.find("
") + 7 : raw_text.find("")]
-
- if not self.title and self.extract:
+ soup = BeautifulSoup(raw_text, "html.parser")
+ title_tag = soup.find("title")
+ if title_tag and title_tag.string:
+ self.title = title_tag.string
+ elif not self.title and self.extract:
first_line = self.extract.split("\n")[0]
self.title = first_line[:254]