本帖最后由 无符号整形 于 2016-9-17 11:33 编辑 def gettitle(url):
title=bs.find('span',{"class":"zm-editable-content"})#找到标题
title=title.get_text()
return(title)
=>def gettitle(url):
title=bs.find('span',{"class":"zm-editable-content"})#找到标题
title=title.get_text()
return(title)
for x in urls:
try:
imgdata=urllib.request.urlopen(x).read()
b = (x.rfind("."))
imgpath=str(dirpath)+str(a)+x[b:]
print(imgpath)
print(x)
a+=1
file=open(imgpath,'wb')
file.write(imgdata)
file.flush()
file.close()
except:
continue
=>for x in urls:
try:
imgdata=urllib.request.urlopen(x).read()
b = (x.rfind("."))
imgpath=str(dirpath)+str(a)+x[b:]
print(imgpath)
print(x)
a+=1
file=open(imgpath,'wb')
file.write(imgdata)
file.flush()
file.close()
except:
continue
def downpics():
title=gettitle(url)
print(title)
dirpath='f:/知乎/'+title+"/"
if not os.path.exists(dirpath):
os.makedirs(dirpath)#生成了问题标题相应的文件夹
pics=getpicurl(url)
a=1
urls=[]
=>def downpics():
title=gettitle(url)
print(title)
dirpath='f:/知乎/'+title+"/"
if not os.path.exists(dirpath):
os.makedirs(dirpath)#生成了问题标题相应的文件夹
pics=getpicurl(url)
a=1
urls=[]
|