欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

串联JVM的指令集文档 博客分类: Python pythonbeautifulsoupjvm 

程序员文章站 2024-02-10 11:39:04
...
from BeautifulSoup import BeautifulSoup

AllFile = open("/home/me/Documents/JavaRelated/vmspec/AllInstuctionsSet.doc.html" , 'w')
FirstFileName = "/home/me/Documents/JavaRelated/vmspec/Instructions2.doc.html"
class SubInstructions:
        def __init__(self,index):
                self.index = index
                self.filename = "/home/me/Documents/JavaRelated/vmspec/Instructions2.doc%d.html" % index
                self.filecontent = open(self.filename).read()
                self.soup = BeautifulSoup(self.filecontent)
        def getFileName(self):
                return self.filename
        def getContents(self):
                return self.soup.body.contents;
AllSoup = BeautifulSoup(open(FirstFileName).read())
for i in range(1,16):
        subInstr = SubInstructions(i)
        print subInstr.getFileName()
        for tag in subInstr.getContents():
                AllSoup.body.append(tag)
AllFile.write(AllSoup.prettify())
AllFile.flush()
AllFile.close()