X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=nhentai%2Fparser.py;h=e9cb4c56a5c085ce6d139d5046934022e3c9e6b2;hb=3a52e8a8bcf26791dd24b33c89f27b430387b925;hp=f068670232884d996069e631e1e04a0d1177434e;hpb=bf8205efbea92f25742ce29f11a6c7297e5a559b;p=nhentai.git diff --git a/nhentai/parser.py b/nhentai/parser.py index f068670..e9cb4c5 100644 --- a/nhentai/parser.py +++ b/nhentai/parser.py @@ -11,20 +11,20 @@ from tabulate import tabulate def request(method, url, **kwargs): if not hasattr(requests, method): - raise AttributeError('\'requests\' object has no attribute \'{}\''.format(method)) + raise AttributeError('\'requests\' object has no attribute \'{0}\''.format(method)) return requests.__dict__[method](url, proxies=constant.PROXY, **kwargs) def doujinshi_parser(id_): if not isinstance(id_, (int,)) and (isinstance(id_, (str,)) and not id_.isdigit()): - raise Exception('Doujinshi id({}) is not valid'.format(id_)) + raise Exception('Doujinshi id({0}) is not valid'.format(id_)) id_ = int(id_) - logger.log(15, 'Fetching doujinshi information of id {}'.format(id_)) + logger.log(15, 'Fetching doujinshi information of id {0}'.format(id_)) doujinshi = dict() doujinshi['id'] = id_ - url = '{}/{}/'.format(constant.DETAIL_URL, id_) + url = '{0}/{1}/'.format(constant.DETAIL_URL, id_) try: response = request('get', url).content @@ -71,14 +71,14 @@ def doujinshi_parser(id_): def search_parser(keyword, page): - logger.debug('Searching doujinshis of keyword {}'.format(keyword)) + logger.debug('Searching doujinshis of keyword {0}'.format(keyword)) result = [] try: response = request('get', url=constant.SEARCH_URL, params={'q': keyword, 'page': page}).content except requests.ConnectionError as e: logger.critical(e) logger.warn('If you are in China, please configure the proxy to fu*k GFW.') - raise SystemExit + exit(1) html = BeautifulSoup(response) doujinshi_search_result = html.find_all('div', attrs={'class': 'gallery'})