Skip to content

Instantly share code, notes, and snippets.

@iwinux
Created November 1, 2011 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iwinux/1329678 to your computer and use it in GitHub Desktop.
Save iwinux/1329678 to your computer and use it in GitHub Desktop.
Print out GR items' title and url
#! /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()
@iwinux
Copy link
Author

iwinux commented Nov 1, 2011

使用方法

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 文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment