四、获取远程URL图片

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import re
import urllib

def getHtml(url):
    page = urllib.urlopen(url)
    html = page.read()
    return html

def getImg(html):
    reg = r'src=\'(.+?\.jpg)\''
    imgre = re.compile(reg)
    imglist = re.findall(imgre,html)
    print(imglist.__len__())
    return imglist

str = getHtml("http://www.ln2car.com")

print(getImg(str));

 

posted @ 2016-01-06 15:46  王树羽  阅读(389)  评论(0编辑  收藏  举报