Python爬取贴吧图片
来源:互联网 发布:js提示框美化 编辑:程序博客网 时间:2024/06/07 02:03
#!/usr/bin/env python# -*- coding: utf-8 -*-# @Time : 2017/7/19 16:21# @Author : wqj# @Contact : wqjhky@gmail.com# @Site : # @File : img.py# @Software: PyCharm Community Editionimport reimport urllibimport sysimport osreload(sys)sys.setdefaultencoding('utf8')def getHtml(url): page = urllib.urlopen(url) html = page.read() return htmldef getImg(html, x): reg = r'src="(http://img.*?\.jpg)"' imgre = re.compile(reg) imList = re.findall(reg, html) print(imList) for i in imList: print(i) print x urllib.urlretrieve(i, '%s.jpg' % x) x += 1 return xx = 1url = "http://tieba.baidu.com/f?ie=utf-8&kw=%E6%B2%B3%E5%8D%97%E7%A7%91%E6%8A%80%E5%AD%A6%E9%99%A2&fr=search?pn="for k in range(1, 28): ul = url + str(k) print ul html = getHtml(ul) # print html x = getImg(html, x) dirpath = r'D:\img' filename = os.path.join(dirpath, str(x) + ".jpg")
阅读全文
1 0
- [Python爬虫]爬取贴吧图片
- Python爬取贴吧图片
- python爬取贴吧图片
- 用Python 爬虫爬取贴吧图片
- Python爬虫入门——爬取贴吧图片
- Python爬虫__爬取贴吧图片和文本
- 使用Python爬虫爬取贴吧图片数据
- Python第一个爬虫(爬取贴吧图片)
- Python 图片处理-图片翻转
- Python 图片处理-图片翻转
- [图片]Ruby vs Python
- python 图片搜索
- Python 图片拼接
- 一张图片入门Python
- python抓取网页图片
- python-Image处理图片
- Python批量下载图片
- python 抓图片
- Win7系统Visual Studio 2013配置OpenCV3.1图文详解
- git学习笔记(一)
- C/C++动态内存分配
- Mac Terminal 终端 快捷键
- Matplotlib的使用
- Python爬取贴吧图片
- liunx基础1
- Json 和 RapidJson
- 原生封装ajax
- 移动端安卓ios车牌识别OCR识别
- MySQL事务的幻读
- CodeVS 1094 FBI树 题解
- B
- Matlab中使用xlswrite函数时出现服务器出现异常的解决方法