Created
November 1, 2011 02:35
-
-
Save iwinux/1329678 to your computer and use it in GitHub Desktop.
Print out GR items' title and url
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import sys | |
import json | |
from HTMLParser import HTMLParser | |
def main(): | |
if (len(sys.argv) != 2): | |
print('No filename specified.') | |
sys.exit(1) | |
filename = sys.argv[1] | |
f = open(filename) | |
data = json.load(f) | |
parser = HTMLParser() | |
for item in data['items']: | |
title = parser.unescape(item['title']) | |
url = item['alternate'][0]['href'] | |
print('%s %s\n' % (title, url)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用方法
python reader.py /media/data/Downloads/starred-items.json
输出效果
Mozilla研究—minimo的本地化 http://blog.csdn.net/absurd/archive/2007/03/14/1529529.aspx
Mozilla研究—传输协议 http://blog.csdn.net/absurd/archive/2007/03/12/1527334.aspx
Mozilla研究—XPCOM语言无关性的实现原理 http://blog.csdn.net/absurd/archive/2007/03/08/1524699.aspx
Mozilla研究—组件的创建过程 http://blog.csdn.net/absurd/archive/2007/03/06/1522589.aspx
改进方向
目前只是很偷懒地在命令行打印出了标题和 URL,其实可以直接写成一个 HTML 文件。