#!/usr/bin/env python import urllib.request from bs4 import beautifulsoup def crawl(url): headers = {'user-agent':'mozilla/5.0 (windows; u; windows nt 6.1; en-us; rv:1.9.1.6) gecko/20091201 firefox/3.5.6'} req = urllib.request.request(url, headers=headers) page = urllib.request.urlopen(req, timeout=20) contents = page.read() soup = beautifulsoup(contents) my_girl = soup.find_all('img') for girl in my_girl: link = girl.get('src') print(link) content2 = urllib.request.urlopen(link).read() with open(u'd:\doubanmeizi' '/' link[-11:],'wb') as code: code.write(content2) page_start = 0 page_stop = 10 for page in range(page_start, page_stop): page = 1 url = 'http://www.51sjk.com/upload/articles/1/0/321/321106_20220812161021372.jpg' % page crawl(url) print("哈哈,妹子图片下载完毕啦!")
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....