標籤:style blog http color os io html 代碼
cocos2d-x是一個很好的跨平台遊戲引擎,更多介紹可查看中文官網,裡面有很多教程,但是排版的不是很好,不方便查看全部,寫了個指令碼抓了一下,產生簡單的網頁,全域查看比較方便,代碼如下
# -*- coding: utf-8 -*-import urllib2firsturl="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 ‘>><‘ in line2: tempurl2 =firsturl+line2.split(‘>‘)[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&per_page=‘ in line and ‘>><‘ in line: tempurl = firsturl+line.split(‘>‘)[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文檔。