Compare commits
No commits in common. "03c119155081f7b9f65e1f55d3a58708c9dc6704" and "d84503055748c6675ff6938d498dc58eb952a7f8" have entirely different histories.
03c1191550
...
d845030557
5 changed files with 5 additions and 19 deletions
|
|
@ -21,7 +21,7 @@ from chardet.universaldetector import UniversalDetector
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
# Default headers for HTTP requests.
|
# Default headers for HTTP requests.
|
||||||
DEFAULT_HEADERS = {
|
DEFAULT_HEADERS = {
|
||||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0',
|
||||||
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
|
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
|
||||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
||||||
'Accept-Language': 'en-US,en;q=0.8,fr;q=0.6,de;q=0.4',
|
'Accept-Language': 'en-US,en;q=0.8,fr;q=0.6,de;q=0.4',
|
||||||
|
|
|
||||||
|
|
@ -199,11 +199,6 @@ class Imdb(SiteParser):
|
||||||
'summary': zebra_table('Plot Summary', more=[
|
'summary': zebra_table('Plot Summary', more=[
|
||||||
'<p>(.*?)<em'
|
'<p>(.*?)<em'
|
||||||
]),
|
]),
|
||||||
'storyline': {
|
|
||||||
'page': '',
|
|
||||||
're': '<h2>Storyline</h2>.*?<p>(.*?)</p>',
|
|
||||||
'type': 'string'
|
|
||||||
},
|
|
||||||
'posterId': {
|
'posterId': {
|
||||||
'page': 'reference',
|
'page': 'reference',
|
||||||
're': '<img.*?class="titlereference-primary-image".*?src="(.*?)".*?>',
|
're': '<img.*?class="titlereference-primary-image".*?src="(.*?)".*?>',
|
||||||
|
|
@ -522,13 +517,10 @@ class Imdb(SiteParser):
|
||||||
])
|
])
|
||||||
if self['releasedate'] == 'x':
|
if self['releasedate'] == 'x':
|
||||||
del self['releasedate']
|
del self['releasedate']
|
||||||
|
|
||||||
if 'summary' not in self and 'storyline' in self:
|
|
||||||
self['summary'] = self.pop('storyline')
|
|
||||||
if 'summary' in self:
|
if 'summary' in self:
|
||||||
if isinstance(self['summary'], list):
|
if isinstance(self['summary'], list):
|
||||||
self['summary'] = self['summary'][0]
|
self['summary'] = self['summary'][0]
|
||||||
self['summary'] = strip_tags(self['summary'].split('</p')[0]).split(' Written by\n')[0].strip()
|
self['summary'] = self['summary'].split('</p')[0].strip()
|
||||||
|
|
||||||
if 'credits' in self:
|
if 'credits' in self:
|
||||||
credits = [
|
credits = [
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
import re
|
import re
|
||||||
from multiprocessing.pool import ThreadPool
|
|
||||||
|
|
||||||
from six import string_types
|
from six import string_types
|
||||||
|
|
||||||
|
|
@ -29,7 +28,6 @@ def cleanup(key, data, data_type):
|
||||||
class SiteParser(dict):
|
class SiteParser(dict):
|
||||||
baseUrl = ''
|
baseUrl = ''
|
||||||
regex = {}
|
regex = {}
|
||||||
pool = ThreadPool(8)
|
|
||||||
|
|
||||||
def get_url(self, page):
|
def get_url(self, page):
|
||||||
return "%s%s" % (self.baseUrl, page)
|
return "%s%s" % (self.baseUrl, page)
|
||||||
|
|
@ -41,9 +39,6 @@ class SiteParser(dict):
|
||||||
|
|
||||||
def __init__(self, timeout=-1):
|
def __init__(self, timeout=-1):
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
urls = list(set(self.get_url(self.regex[key]['page']) for key in self.regex))
|
|
||||||
self.pool.map(self.get_url, urls)
|
|
||||||
|
|
||||||
for key in self.regex:
|
for key in self.regex:
|
||||||
url = self.get_url(self.regex[key]['page'])
|
url = self.get_url(self.regex[key]['page'])
|
||||||
data = self.read_url(url, timeout)
|
data = self.read_url(url, timeout)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
chardet
|
chardet
|
||||||
six>=1.5.2
|
six>=1.5.2
|
||||||
lxml
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue