美文网首页
2017-12-16

2017-12-16

作者: 伍之杨 | 来源:发表于2017-12-16 17:07 被阅读0次

#coding=utf-8

import urllib

import re

def getHtml(url):

    page = urllib.urlopen(url)

    html = page.read()

    return html

def getImg(html):

    reg = r'src="(.+?\.jpg)" pic_ext'

    imgre = re.compile(reg)

    imglist = re.findall(imgre,html)

    x = 0

    for imgurl in imglist:

        urllib.urlretrieve(imgurl,'%s.jpg' % x)

        x+=1

html = getHtml("http://7mx.com/photo/444648")

print getImg(html)

相关文章

网友评论

      本文标题:2017-12-16

      本文链接:https://www.haomeiwen.com/subject/cvaswxtx.html