cocos2d-x学习笔记

cocos2d-x是一个很好的跨平台游戏引擎,更多介绍可查看中文官网,里面有很多教程,但是排版的不是很好,不方便查看全部,写了个脚本抓了一下,生成简单的网页,全局查看比较方便,代码如下

# -*- coding: utf-8 -*-
import urllib2


firsturl="http://cn.cocos2d-x.org/"
def main():
    file = open("index.html","w")
    writehead(file)
    writetable(file)
    writeend(file)
    file.close()


def writetable(file):
    file.write('<table width="100%" border="2" cellpadding="2" cellspaceing="0">')
    result = urllib2.urlopen(firsturl+"tutorial/index")
    line = result.readline()
    while line:
        if '<a href="/tutorial/lists?id=' in line and '<img' not in line:
            file.write("<tr><td>")
            file.write(line.replace("/tutorial",firsturl+"/tutorial"))
            cuturl = firsturl+line.split("href")[1].split('"')[1]
            result2 = urllib2.urlopen(cuturl)
            line2 = result2.readline()
            file.write("</td><td><ul>")
            while line2:
                if '<a href="/tutorial/show?id' in line2 and '<img' not in line2:
                    file.write("<li>")
                    file.write(line2.replace("/tutorial",firsturl+"/tutorial"))
                    file.write("</li>")
                if '<a href="/tutorial/lists?id=' in line2 and '>&gt;<' in  line2:
                    tempurl2 =firsturl+line2.split('&gt')[0].split('"')[-2][1:].replace("amp;","")
                    print tempurl2
                    result2 = urllib2.urlopen(tempurl2)
                line2 = result2.readline()
            file.write("</ul></td></tr>")
        if '<a href="/tutorial/index?level=0&type=cocos2d-x&amp;per_page=' in line and '>&gt;<' in line:
            tempurl = firsturl+line.split('&gt')[0].split('"')[-2][1:].replace("amp;","")
            result = urllib2.urlopen(tempurl)
            #print tempurl
        line =result.readline()
    file.write("</table>")


def writehead(file):
    file.write('''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>
</head>
<body>
''')

def writeend(file):
    file.write('''</body>
</html>
''')


main()

简单粗暴的爬了下来之后,觉得类之间的关系要能弄清楚就好了,于是发现了个好东西叫doxygen,非常好用,从源码生成html文档。

原文地址:https://www.cnblogs.com/727713-chuan/p/3880823.html