用python试着简单爬取下360图片的图片
2020-02-17 04:37
357 查看
用python试着简单爬取下360图片的图片
用python试着简单爬取下360图片的图片
import re import requests #抓取源代码 fs = open('source1.txt','wb') url = "http://image.so.com/" ctext = requests.get(url) fs.write(ctext.content) fs.close() fs = open('source1.txt','r') html = fs.read() fs.close() #匹配图片网址 pic_url = re.findall('src="(.*?)"',html,re.S) i=0 for each in pic_url: if re.findall('jpg',each): print 'now downloading:'+each pic = requests.get(each) fp = open('pic\\'+str(i)+'.jpg','wb') fp.write(pic.content) fp.close() i+=1 if re.findall('png',each): print 'now downloading:'+each pic = requests.get(each) fp = open('pic\\'+str(i)+'.png','wb') fp.write(pic.content) fp.close() i+=1
posted on 2016-07-08 20:01 ArvinShaffer 阅读(...) 评论(...) 编辑 收藏
转载于:https://www.cnblogs.com/ArvinShaffer/articles/5654454.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- python简单应用urllib2
- python实现简单爬虫
- python-cursor
- 使用vscode 写python 时,用Code Runner遇到的坑!
- python爬虫——爬去淘宝商品页面,总是跳转到登录界面
- python爬虫——requests.exceptions.InvalidHeader: Invalid return character or leading space in header: co
- 【Python】NameError: name 'self' is not defined
- [Python]Numpy读取npz文件并且使用matplotlib绘制散点图和折线图
- python中的lambda函数用法
- ubuntu18.04中sudo python路径修改
- 自学python之Django遇到的坑(一)
- 利用极简入门级Python代码实现任意区域OCR工具,文本显示形式可控
- 用stanfordcorenlp在python下的评论抽取和分析
- python append 和 extend 的区别
- python3中的 __new__() 与 __init__()
- python函数修饰器
- cenos上面python3及mysql的安装
- 《Python3程序开发指南(第二版)》例题之多线程文件查找关键词
- python导入模块
- python实现用户好友推荐