python正则图片爬取
# conding:utf8
import requests
import re
import time
if __name__ == "__main__":
# 所有的数据
url = 'http://www.win4000.com/zt/qsmy.html'
response = requests.get(url)
# with open('./qsmy.html', mode='w', encoding='utf-8') as fp:
# fp.write(response.text)
# print('网页中的内容保存成功')
# 我们想要的数据
# <img src="http://static.win4000.com/home/images/placeholder.jpg" data-original = "http://pic1.win4000.com/wallpaper/5/53bcec5b3235b_270_185.jpg" />
pattern = r'<img src=".*?" data-original = "(.*?)" />'
html = response.text
imahe_urls = re.findall(pattern, html)
print(imahe_urls)
for img_url in imahe_urls:
print(img_url)
response = requests.get(img_url)
content = response.content
file = img_url.rsplit('/', maxsplit=1)[1]
with open('./tupian/%s' % file, mode='wb') as fp:
fp.write(content)
print('图片%s保存成功!' % file)
time.sleep(1)
python正则图片爬取的更多相关文章
- python+正则+多进程爬取糗事百科图片
话不多说,直接上代码: # 需要的库 import requests import re import os from multiprocessing import Pool # 请求头 header ...
- python xpath图片爬取
import requests from urllib.request import urlretrieve from lxml import etree headers = { 'User-Agen ...
- Python+Requests+Re(正则)爬取某糗事百科图片(数据分析一)
1.博客目前在学习爬虫课程,使用正则表达式来爬取网页的图片信息 2.下面我们一起来回归下Python中的正则使用方式/方法 3.糗事百科图片爬取源码如下: import requestsimport ...
- Python简易爬虫爬取百度贴吧图片
通过python 来实现这样一个简单的爬虫功能,把我们想要的图片爬取到本地.(Python版本为3.6.0) 一.获取整个页面数据 def getHtml(url): page=urllib.requ ...
- 【Python】Python简易爬虫爬取百度贴吧图片
通过python 来实现这样一个简单的爬虫功能,把我们想要的图片爬取到本地.(Python版本为3.6.0) 一.获取整个页面数据 def getHtml(url): page=urllib.requ ...
- Python爬虫入门教程 26-100 知乎文章图片爬取器之二
1. 知乎文章图片爬取器之二博客背景 昨天写了知乎文章图片爬取器的一部分代码,针对知乎问题的答案json进行了数据抓取,博客中出现了部分写死的内容,今天把那部分信息调整完毕,并且将图片下载完善到代码中 ...
- [python] 常用正则表达式爬取网页信息及分析HTML标签总结【转】
[python] 常用正则表达式爬取网页信息及分析HTML标签总结 转http://blog.csdn.net/Eastmount/article/details/51082253 标签: pytho ...
- [Python爬虫] Selenium爬取新浪微博客户端用户信息、热点话题及评论 (上)
转载自:http://blog.csdn.net/eastmount/article/details/51231852 一. 文章介绍 源码下载地址:http://download.csdn.net/ ...
- 利用Python网络爬虫爬取学校官网十条标题
利用Python网络爬虫爬取学校官网十条标题 案例代码: # __author : "J" # date : 2018-03-06 # 导入需要用到的库文件 import urll ...
随机推荐
- 使用Java操作Elasticsearch(Elasticsearch的java api使用)
1.Elasticsearch是基于Lucene开发的一个分布式全文检索框架,向Elasticsearch中存储和从Elasticsearch中查询,格式是json. 索引index,相当于数据库中的 ...
- C# ICloneable,shallow clone,deep clone.
[Serializable] public class Person:ICloneable { public string Name { get; set; } public int Id { get ...
- mac安装linux
http://www.mamicode.com/info-detail-503881.html
- [20190918]关于函数索引问题.txt
[20190918]关于函数索引问题.txt 1.环境:SCOTT@test01p> @ ver1PORT_STRING VERSION BA ...
- zsh: command not found: 解决方法
问题原有:mac中安装了my zsh [https://www.cnblogs.com/dadonggg/p/11027454.html] ,但是造成了在使用vscode的时候,提示”zsh: com ...
- VS2019专业版和企业版激活密钥
Visual Studio 2019 Professional NYWVH-HT4XC-R2WYW-9Y3CM-X4V3Y Visual Studio 2019 EnterpriseBF8Y8-GN2 ...
- windows系统下mount创建的.vhd
自己无聊时候分出了几个磁盘用来练习,存放个人东西,cdef盘除了c盘都是随便乱存的(粗心-_-),于是分出了两个20G的vhd文件,但是每次开机都要去d盘点击挂载太麻烦,现在分享自己的方法. 创建mo ...
- 【西北师大-2108Java】第四次作业成绩汇总
[西北师大-2108Java]第四次作业成绩汇总 深入理解程序设计中算法与程序的关系: 深入理解java程序设计中类与对象的关系: 理解OO程序设计的第2个特征:继承.多态: 学会采用继承定义类设计程 ...
- selenium添加chrome配置项
selenium虽然强大,但也有不方便的地方,selenium每次启动浏览器都是一个全新的浏览器,并没有加载任何的配置,这样在爬取一些需要登陆才能看到的页面时就有些不太方便.但我们可以通过加载chro ...
- python爬虫之深度爬取实例
写了一个之前没完成的项目,代码优化不够,速度有点慢,应该也有错误的地方,望大佬看了之后能给点建议......... 这是开始的url,先看一下它的网页结构:http://www.cymodel.net ...