简单的python爬虫下载

暗月博客 2019年11月21日16:03:16评论355 views字数 350阅读1分10秒阅读模式
摘要

最近研究一下python 准备写几个大杀器 内部用

#!/usr/bin/python import re import urllib def getHtml(url):     page=urllib.urlopen(url)     html=page.read()     return html  def getImg(html):     reg = r'<img src="(.*?/.jpg)">'     imgre=re.compile(reg)     imglist = re.findall(imgre,html)     x=0     for imgurl in imglist:         urllib.urlretrieve(imgurl,'%s.jpg' % x)         print '%s.jpg' % x         x+=1 html=getHtml("http://www.moonhack.org") getImg(html)

简单的python爬虫下载

最近研究一下python 准备写几个大杀器 内部用

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
暗月博客
  • 本文由 发表于 2019年11月21日16:03:16
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   简单的python爬虫下载https://cn-sec.com/archives/71037.html

发表评论

匿名网友 填写信息