废话不多说,直接上源码。

import os,urllib,urllib2,re
path='E:/img' #图片保存路径
url=raw_input('Please input URL:')#贴吧地址
pn=1 #贴吧页码
while 1:
address=url+'?'+'pn='+str(pn)#当前页地址
try:
html=urllib2.urlopen(address).read()#读取当前页html
print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!page%d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'%(pn)
except:
print 'TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT'
exit(0)
m=re.findall('http://imgsrc.baidu.com/forum/w%3D580/sign=.*?\.jpg',html)#利用正则表达式分析图片URL
for i in range(0,len(m)):
print m[i]
n=re.search('sign=(.*?)/',m[i])#提取图片URL部分字符串作为文件名
file_name=n.group(1)+'.jpg'
file_name=os.path.join(path,file_name)
try:
print 'loading...'
urllib.urlretrieve(m[i],file_name)#下载图片
print 'this picture down complete.'
except:
print 'error'
pn=pn+1#翻页

最新文章

  1. JavaScript中事件处理
  2. B-index、bitmap-index、text-index使用场景详解
  3. jQuery知识点总结(第二天)
  4. C语言中常用的string.h的字符函数
  5. EAS使用中FineUI的配置
  6. cocos2dx 2.x mac proj 开启模板
  7. iptables的recent模块
  8. [设计模式] 8 组合模式 Composite
  9. CMake 入门实战 | HaHack
  10. SKAction类
  11. Square spiral
  12. Project configuration is not up-to-date with pom.xml错误解决方法
  13. bootstrap validator html attributes 选项
  14. .net core使用RPC方式进行高效的HTTP服务访问
  15. redis conf 中文详解
  16. visual studio code常用插件
  17. 大话设计模式之模板模式 C#
  18. 经典贪心算法(哈夫曼算法,Dijstra单源最短路径算法,最小费用最大流)
  19. MySQL防范SQL注入风险
  20. bzoj 1934 最小割

热门文章

  1. [读书笔记]了不起的node.js(二)
  2. UVA 10806 Dijkstra, Dijkstra.(费用流)
  3. ELK beats通用配置说明(12th)
  4. Vim Skills——Windows利用Vundle和Github进行Vim配置和插件的同步
  5. UITabBarController详解
  6. android131 360 02 设置中心
  7. NET中間語言(IL) 图解
  8. 解决Windows2008Server上PLSQL登录时报ORA-12557
  9. 原 Debian设置开机自动启动与关闭
  10. mysql之sql语句细节问题汇总