Skip to content

Commit

Permalink
Show error message on login failure
Browse files Browse the repository at this point in the history
  • Loading branch information
dipu-bd committed Jul 12, 2018
1 parent 35ef16f commit 6662ca4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions EbookCrawler/lnmtl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class LNMTLCrawler:
'''Crawler for LNMTL'''

executor = concurrent.futures.ThreadPoolExecutor(max_workers=10)
executor = concurrent.futures.ThreadPoolExecutor(max_workers=5)

def __init__(self, novel_id, start_chapter=None, end_chapter=None):
if not novel_id:
Expand Down Expand Up @@ -80,7 +80,14 @@ def login(self):
self.headers['cookie'] = '; '.join([x.name + '=' + x.value for x in response.cookies])
soup = BeautifulSoup(response.text, 'lxml')
logout = soup.select_one('a[href="%s"]' % self.logout_url)
return logout is not None
if logout is None:
print('-' * 80)
body = soup.select_one('body').text
print('\n\n'.join([x for x in body.split('\n\n') if len(x.strip())]))
print('-' * 80)
return False
# end if
return True
# end def

def logout(self):
Expand Down

0 comments on commit 6662ca4

Please sign in to comment.