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..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" @@ -6,19 +6,14 @@ 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函数获取图片 - ''' + #获取每个页面的套图列表,之后循环调用get_pic函数获取图片 soup = BeautifulSoup(html, 'html.parser') pic_list = soup.find_all('li', class_='wp-item') for i in pic_list: @@ -27,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') # 找到界面所有图片