Иногда тэг размера не имеет нужного класса

master
Бородин Роман 2020-05-07 19:29:42 +03:00
parent 2bb8f0e60f
commit 27ddd8a9ac
1 changed files with 2 additions and 1 deletions

View File

@ -27,7 +27,8 @@ class SearchEngine(Searcher):
seeders_el = r.find('.//*[@class="seedmed"]')
seeders = int(seeders_el.text.strip() if seeders_el is not None else 0)
leachers = int(list(filter(lambda x: 'leechmed' in x.attrib['class'], r.findall('.//td')))[0].text.strip())
size = ' '.join(list(filter(lambda x: 'tor-size' in x.attrib['class'], r.findall('.//td')))[0].find('.//a').text.strip().split(' ')[:2])
size_tag = list(filter(lambda x: 'tor-size' in x.attrib['class'], r.findall('.//td')))[0].find('.//a')
size = ' '.join(size_tag.text.strip().split(' ')[:2]) if size_tag is not None else '<N/A>'
yield ResultItem(url, title, size, seeders, leachers, self.icon, self.cookies, self.base_url)
def login(self):
user = option['rutracker_login']