From 8319857450d36e0ebd927d4db0f2b8d13b40be3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E5=95=9F=E5=8D=8E?= <1029559041@qq.com> Date: Fri, 6 Sep 2019 19:05:00 +0800 Subject: [PATCH] =?UTF-8?q?docker=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PixivSearch/pixiv/pixiv.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PixivSearch/pixiv/pixiv.py b/PixivSearch/pixiv/pixiv.py index d01febd..01e3c56 100644 --- a/PixivSearch/pixiv/pixiv.py +++ b/PixivSearch/pixiv/pixiv.py @@ -24,12 +24,9 @@ headers = { lock = threading.Lock() # 多线程全局资源锁 total = 1 - -address = '127.0.0.1:1080' +address = '127.0.0.1:8118' # proxies = {"http": "socks5://{0}".format(address), "https": "socks5://{0}".format(address)} - - -proxies={"http": address,"https": address} +proxies = {"http": "http://{0}".format(address), "https": "https://{0}".format(address)} def get_cookies(): _cookies = {} @@ -41,7 +38,11 @@ def get_cookies(): def getReq(url, **kwargs): - return requests.get(url, headers=headers, cookies=get_cookies(), proxies=proxies, **kwargs) + try: + return requests.get(url, headers=headers, cookies=get_cookies(), proxies=proxies, **kwargs) + except Exception as e: + logger.error(e) + raise e def crawl(url):