Commit 303c8a75 authored by Jonathan Harker's avatar Jonathan Harker

Update to work with Python 3

 - Replace Mechanize with BeautifulSoup.
 - Adjust requirements.txt for updated dependencies.
parent 3c366bb5
from mechanize import Browser
#! /usr/bin/env python
Database models for lolbot.
from __future__ import print_function, unicode_literals
import requests
from datetime import datetime
from bs4 import BeautifulSoup
from sqlalchemy import (Column, String, Text, Integer, DateTime)
from sqlalchemy.ext.declarative import (declarative_base)
......@@ -59,9 +67,8 @@ class Url(Model):
# populate the title from the URL if not given.
if title is None:
br = Browser()
self.title = br.title()
dom = BeautifulSoup(requests.get(self.url), 'html.parser')
self.title = dom.title.string
except Exception:
self.title = ''
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