From e8bf2c2044b152ce2c7e0a68f1f2f54de2e70842 Mon Sep 17 00:00:00 2001 From: Ching Date: Fri, 11 Jun 2021 11:05:11 +0800 Subject: [PATCH] [M]jandan_pic_url to https --- jandan_toot.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/jandan_toot.py b/jandan_toot.py index 9327075..d409ff4 100644 --- a/jandan_toot.py +++ b/jandan_toot.py @@ -65,20 +65,14 @@ def toot(proxy=None): while page_count and jandan_pic_url: resp = session.get(jandan_pic_url, timeout=2) - retry_count = 5 - if resp.status_code != 200 and retry_count: - proxy = get_proxy().get('proxy') - session.proxies.update({"https": "https://{}".format(proxy)}) + if resp.status_code != 200: time.sleep(10) - retry_count -= 1 continue - if retry_count <= 0 and resp.status_code != 200: - raise ValueError('http status not 200') soup = BeautifulSoup(resp.content, 'html.parser') jandan_pic_url = soup.find(class_='previous-comment-page')['href'] page_count -= 1 if jandan_pic_url.startswith('//'): - jandan_pic_url = 'http:' + jandan_pic_url + jandan_pic_url = 'https:' + jandan_pic_url pic_nodes = soup.find('ol').find_all('li')