From a3200cc31920a1b2a0ec7d900277fac9bee980d0 Mon Sep 17 00:00:00 2001 From: mjy0424 <65580735+mjy0424@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:37:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meizitu.py" | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git "a/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" "b/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" index 4f6932db..3ee40755 100644 --- "a/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" +++ "b/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" @@ -6,15 +6,12 @@ def download_page(url): - ''' - 用于下载页面 - ''' + #用于下载页面 headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0"} r = requests.get(url, headers=headers) r.encoding = 'gb2312' return r.text - def get_pic_list(html): ''' 获取每个页面的套图列表,之后循环调用get_pic函数获取图片 From 6f645ff2202abb354a3dfa43e186c9d6e1d15ce7 Mon Sep 17 00:00:00 2001 From: mjy0424 <65580735+mjy0424@users.noreply.github.com> Date: Tue, 28 Jul 2020 12:39:45 +0800 Subject: [PATCH 2/2] Update meizitu.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 大家好,我是新手,请多多指教,谢谢! --- .../meizitu.py" | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git "a/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" "b/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" index 3ee40755..271c14e2 100644 --- "a/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" +++ "b/\347\210\254\350\231\253\351\233\206\345\220\210/meizitu.py" @@ -13,9 +13,7 @@ def download_page(url): return r.text def get_pic_list(html): - ''' - 获取每个页面的套图列表,之后循环调用get_pic函数获取图片 - ''' + #获取每个页面的套图列表,之后循环调用get_pic函数获取图片 soup = BeautifulSoup(html, 'html.parser') pic_list = soup.find_all('li', class_='wp-item') for i in pic_list: @@ -24,11 +22,8 @@ def get_pic_list(html): text = a_tag.get_text() get_pic(link, text) - def get_pic(link, text): - ''' - 获取当前页面的图片,并保存 - ''' + #获取当前页面的图片,并保存 html = download_page(link) # 下载界面 soup = BeautifulSoup(html, 'html.parser') pic_list = soup.find('div', id="picture").find_all('img') # 找到界面所有图片