NewsSpider/news_spider/show.py

31 lines
634 B
Python
Raw Normal View History

#!/usr/bin/python
import json
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
file = open(sys.argv[1])
c=0
while 1:
line = file.readline()
if not line:
break
data = json.loads(line)
c+=1
2016-04-24 00:16:16 +08:00
if sys.argv[2] == '1':
print c,"-->",data['time'],data['title'],data['url'],data['content']
else:
print c,"-->",data['time'],data['title'],data['url']
#data = json.load(file)
#c = 0
#for article in data:
# c+=1
# print "[----Time-----]\n",article['time'],article['title']
# print "[----Title----]\n",article['title']
# print article['time'],article['title']
# print "[----Article--]\n",article['content'],"\n\n"
print c