标签:style blog http ar color os 使用 sp for
Code现在由于政府墙的原因,不能直接上安卓官网查看资料
下载sdk时,是通过更改hosts文件,下载下来后,里面会有个docs文件夹,这个也是安卓的官方文档。
但是由于里面需要引用谷歌的资源,所以打不开或者需要极长时间才能打开。
还有就是打开后,浏览器中有个东西会不停的再转啊转的加载东西。对有点强迫证的来说简直是个噩梦。
使用方法:
把下面的代码存成mvgoogle.py文件,放在docs 文件夹下。直接运行即可,使用的是python3.4。
import html.parser import os ulr_google = {'http://fonts.googleapis.com/css?family=Roboto+Condensed', 'http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold', 'http://www.google.com/jsapi', 'http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold', 'http://www.google.com/jsapi', '//swfobject.googlecode.com/svn/trunk/swfobject/swfobject.js', 'http://www.google-analytics.com/ga.js', 'http://fonts.googleapis.com/css?family=Roboto+Condensed', 'http://fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold', '//www.google-analytics.com/analytics.js'} def readfile(filepath, mode='rt', encoding=None): fd = None if encoding: fd = open(filepath, mode=mode, encoding=encoding) else: fd = open(filepath, mode=mode) data = fd.read() fd.close() return data def writefile(data, filepath, mode='w', encoding=None): fd = None if encoding: fd = open(filepath, mode=mode, encoding=encoding) else: fd = open(filepath, mode=mode) fd.write(data) fd.close() # def walk(dirpath, parser): def walk(dirpath): for root, subdirs, files in os.walk(dirpath): for file in files: if not file.endswith('.html'): continue filepath = os.path.join(root, file) data = readfile(filepath) # parser.feed(data) # parser.reset() for gu in ulr_google: data = data.replace(gu, '#') writefile(data, filepath) curpath = os.getcwd() # parser = MyParser() walk(curpath, parser) # ./assests/js/docs.js # move https://apis.google.com/js/plusone.js docsjs = os.join(curpath, 'assests/js/docs.js') data = readfile(docsjs) data = data.replace('https://apis.google.com/js/plusone.js', '#') writefile(data, filepath)
现在就能在本地快速自由地打开文档了。
标签:style blog http ar color os 使用 sp for
原文地址:http://blog.csdn.net/jiangxiaoma111/article/details/41627601