Update to work with Python 3
- Replace Mechanize with BeautifulSoup. - Adjust requirements.txt for updated dependencies.
This commit is contained in:
parent
3c366bb5e2
commit
303c8a7584
2 changed files with 14 additions and 12 deletions
15
models.py
15
models.py
|
|
@ -1,5 +1,13 @@
|
|||
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:
|
||||
try:
|
||||
br = Browser()
|
||||
br.open(self.url)
|
||||
self.title = br.title()
|
||||
dom = BeautifulSoup(requests.get(self.url), 'html.parser')
|
||||
self.title = dom.title.string
|
||||
except Exception:
|
||||
self.title = ''
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
SQLAlchemy==1.0.9
|
||||
argparse==1.2.1
|
||||
irc==11.0.1
|
||||
jaraco.timing==1.1.5
|
||||
jaraco.util==10.6
|
||||
mechanize==0.2.5
|
||||
more-itertools==2.2
|
||||
six==1.10.0
|
||||
wsgiref==0.1.2
|
||||
beautifulsoup4==4.4.1
|
||||
irc==13.2
|
||||
requests==2.8.1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue