html美食网站源码分享(美食网页设计源码)

大家好,今天来为大家解答html美食网站源码分享这个问题的一些问题点,包括美食网页设计源码也一样很多人还不知道,因此呢,今天就来为大家分析分析,现在让我们一起来看看吧!如果解决了您的问题,还望您关注下本站哦,谢谢~

现在有一批完整的关于介绍城市美食、景点等的html页面,需要将里面body的内容提取出来。

方法:利用python插件beautifulSoup获取htmlbody标签的内容,并批量处理。

所有文件夹,第一个字段是此目录的级别

dirList=[]

返回一个列表,其中包含在目录条目的名称

files=os.listdir(path)

排除隐藏文件夹,因为隐藏文件夹过多

if(f[0]==’.’):

pass

else:

添加文件

fileList.append(f)

return(dirList,fileList)

printrootdir+’/’+path+’/’+i

objFile=open(rootdir+’/’+path+’/’+i)

soup=BeautifulSoup(objFile)

arr=[]

forchildinsoup.body:

arr.append(child)

ifos.path.exists(savepath+’/’+path):

pass

else:

os.makedirs(savepath+’/’+path)

f=open(savepath+’/’+path+’/’+temp+’.txt’,’w’)

fork,vinenumerate(arr):

ifk!=1:

f.write(str(v))

f.close()

printpath+’/’+i+’isrunning’

file_num=file_num+1

rootdir=’../zips2′

dirList,fileList=printPath(1,rootdir)

savepath=”../testC”

file_num=0

forfnindirList:

if(fn==’1′):

pass

else:

getAndInsert(rootdir,savepath,fn)

printfn+’isending’

OK,本文到此结束,希望对大家有所帮助。

Published by

风君子

独自遨游何稽首 揭天掀地慰生平