import re
import urllib
def get_content(url):
'''doc.'''
html = urllib.urlopen(url)
content = html.read()
html.close()
return content
def get_image(info):
'''doc.'''
regex = r'class="BDE_Image" src="(.+?\.jpg)"'
pat = re.compile(regex)
image_code = re.findall(pat,info)
i = 0
for image_url in image_code:
print image_url
urllib.urlretrieve(image_url,'%s.jpg'%i)
i += 1
return image_code
url = 'https://tieba.baidu.com/p/27726566630'
info = get_content(url)
# print info
print get_image(info)