Python只需要几十行代码,就可以实现全自动爬取妹子图www.mezitu.com网站大图和高清图片美女图片。

代码片段
import requestsimport osimport timeimport threadingfrom bs4 import BeautifulSoup
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函数获取图片 '''
soup = BeautifulSoup(html, 'html.parser')
pic_list = soup.find_all('li', class_='wp-item')
for i in pic_list:
a_tag = i.find('h3', class_='tit').find('a')
link = a_tag.get('href')
text = a_tag.get_text()
get_pic(link, text)
版权声明
版权说明: 仅限用于学习和研究目的;不得将上述内容用于商业和非法用途!否则一切后果自负。我们非常重视版权问题,如有侵权请邮件至(171373236#qq.com)与我们联系处理,敬请谅解!





















