def __search(self, title, year):
try:
query = self.search_link % (urllib.quote_plus(cleantitle.query(title)))
query = urlparse.urljoin(self.base_link, query)
t = cleantitle.get(title)
y = ['%s' % str(year), '%s' % str(int(year) + 1), '%s' % str(int(year) - 1), '0']
r = client.request(query)
r = dom_parser.parse_dom(r, 'div', attrs={'class': 'movie_single'})
r = dom_parser.parse_dom(r, 'a', attrs={'class': 'unfilm'}, req='href')
r = [(i.attrs['href'], dom_parser.parse_dom(r, 'div', attrs={'class': 'title'}), dom_parser.parse_dom(r, 'span', attrs={'class': 'post-year'})) for i in r]
r = [(i[0], re.sub('<.+?>|</.+?>', '', i[1][0].content), i[2][0].content if i[2] else '0') for i in r if i[1]]
r = sorted(r, key=lambda i: int(i[2]), reverse=True) # with year > no year
r = [i[0] for i in r if t == cleantitle.get(i[1]) and i[2] in y][0]
return source_utils.strip_domain(r)
except:
return
评论列表
文章目录