getjpg.py
import re
import urllib.request
def getHtml(url):
page=urllib.request.urlopen(url)
html=page.read()
return html
def getImg(html):
reg=r'img src="(http.*?)"'
imgre=re.compile(reg)
imglist=re.findall(imgre,html.decode('utf-8'))
x=0
for imgurl in imglist:
urllib.request.urlretrieve(imgurl,'%s.jpg'%x)
x+=1
return imglist
url="https://www.zhihu.com/question/50734809"
#html=getHtml(url)
#print(html)
#print(getImg(html))
getImg(getHtml(url))
import re
import urllib.request