Skip to content

Commit

Permalink
handle requests error
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Apr 14, 2020
1 parent 779b68c commit 90bd1c1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/tools/baidu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import requests
from bs4 import BeautifulSoup

from lib.cli import vwrite, wc, console
from lib.cli import console, vwrite, wc


def get_and_parse(url, page):
Expand All @@ -37,6 +37,10 @@ def get_and_parse(url, page):
# pylint: disable=eval-used
res = eval(result)
vwrite.write_to_file(res['mu'], 'result.txt')

except requests.RequestException as exc:
console.print_error(f"[-] Request error: {exc}")

except BaseException:
console.debug_except()

Expand Down Expand Up @@ -74,6 +78,5 @@ def spider(keyword, count):
except BaseException:
console.debug_except()


# exit progress monitoring when we are done
status.terminate()

0 comments on commit 90bd1c1

Please sign in to comment.