该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#!/usr/bin/python3
#code=utf-8
import urllib.request
import re
path = "C:\\Users\\Administrator\\Pictures\\python\\816\\" #图片下载的地址
#根据网址字符串,读取网页
def getHtml(url):
page = urllib.request.urlopen(url)
html = page.read()
return html
def getUrllist(html):
#reg = r'bpic="(.+?\.jpg)"'
#imgre = re.compile(reg)
#指定编码要求
html = html.decode('utf-8')
# imglist = re.findall(imgre,html)
urllist = re.findall(urlre,html)
imglist = re.findall(imgre, html)
urllib.request.urlretrieve(imgurl, path + 'w%s.jpg' % x)
urllib.request.urlretrieve(imgurl,path+ '%s.jpg' % x)
html = getHtml("http://tieba.baidu.com/f?kw=%D0%A3%BB%A8&fr=ala0&tpl=5")