使用Python下载Bing图片(代码)
2013-11-07 00:00
696 查看
直接上代码:
<span style="font-family: arial,helvetica,sans-serif; font-size: 16px;"># -*- coding: cp936 -*- import urllib import os print 'Download data......' url = 'http://cn.bing.com' urlFile = urllib.urlopen(url) data = urlFile.read() urlFile.close() data = data.decode('utf-8') pre = 'g_img={url:\'' index1 = data.find(pre) + len(pre) index2 = data.find('\'', index1) imgUrl = data[index1 : index2] preImg = u'h3>今日图片故事</h3><a href=' index3 = data.find(preImg) + len(preImg) index4 = data.find('>', index3) + 1 index5 = data.find('<', index4) imgName = data[index4 : index5] +u'.jpg' if os.path.exists(imgName) == False: print 'Download image......' urllib.urlretrieve(imgUrl, imgName) print 'Download complete' os.startfile(imgName) </span>
相关文章推荐
- 使用Python下载Bing图片(代码)
- python中使用urllib下载网站图片
- Python下载Bing主页图片
- python中使用网络爬虫下载图片
- 使用python进行爬虫下载指定网站的图片
- 【教程】记录:python基础爬虫代码(下载妹子福利图片)
- Control Study->AdRotator广告控件显示自定义配置文件中广告以及与DataGrid控件结合使用显示图片(示例代码下载)
- Control Study->AdRotator广告控件显示自定义配置文件中广告以及与DataGrid控件结合使用显示图片(示例代码下载)
- Python3网络爬虫:Scrapy入门之使用ImagesPipline下载图片
- python使用re, os, httplib, urllib批量下载网页上的图片
- python3抓取异步百度瀑布流动态图片(二)get、json下载代码讲解
- python 使用 urllib.urlretrieve()下载网络图片,在本地打开提示文件损坏无法打开
- 使用python下载图片
- Python使用Scrapy爬虫框架全站爬取图片并保存本地的实现代码
- 使用简易Python爬虫下载百度贴吧图片
- Java与Python下载Bing首页图片
- 使用Python脚本将Bing的每日图片作为桌面的教程
- Python使用requests模块下载图片
- Control Study->AdRotator广告控件显示自定义配置文件中广告以及与DataGrid控件结合使用显示图片(示例代码下载)
- 使用python抓取网站代码,并下载里面的url