def __search(self, titles, year, content):
try:
t = [cleantitle.get(i) for i in set(titles) if i]
c = client.request(urlparse.urljoin(self.base_link, self.year_link % int(year)), output='cookie')
p = urllib.urlencode({'search': cleantitle.query(titles[0])})
c = client.request(urlparse.urljoin(self.base_link, self.search_link), cookie=c, post=p, output='cookie')
r = client.request(urlparse.urljoin(self.base_link, self.type_link % content), cookie=c, post=p)
r = dom_parser.parse_dom(r, 'div', attrs={'id': 'content'})
r = dom_parser.parse_dom(r, 'tr')
r = [dom_parser.parse_dom(i, 'td') for i in r]
r = [dom_parser.parse_dom(i, 'a', req='href') for i in r]
r = [(i[0].attrs['href'], i[0].content, i[1].content) for i in r if i]
r = [(i[0], i[1], re.findall('(.+?)\s<i>\((.+?)\)<', i[1]), i[2]) for i in r]
r = [(i[0], i[2][0][0] if len(i[2]) > 0 else i[1], i[2][0][1] if len(i[2]) > 0 else '', i[3]) for i in r]
r = [i[0] for i in r if (cleantitle.get(i[1]) in t or cleantitle.get(i[2]) in t) and i[3] == year][0]
return source_utils.strip_domain(r)
except:
return
评论列表
文章目录