コード例 #1
0
ファイル: demobing.py プロジェクト: iverson0201/python_demo
#    coding: UTF-8
#    User: haku
#    Date: 13-2-12
#    Time: 1:01
#
__author__ = 'haku'
from pyrailgun import RailGun
import sys, urllib

reload(sys)
sys.setdefaultencoding("utf-8")

railgun = RailGun()
railgun.setTask(file("bing.json"))
query = raw_input("Please Input Query\r\n")
railgun.setGlobalData("q", urllib.quote(query))
railgun.fire()
nodes = railgun.getShells()
file = file("demo_bing.txt", "w+")
for id in nodes:
    node = nodes[id]
    print "entry  " + node.get('title', [""])[0]
    file.write(node.get('title', [""])[0] + "\r\n")
    file.write(
        node.get('description', [""])[0] +
        "\r\n====================================\r\n")
コード例 #2
0
#! /usr/bin/env python
# ! coding=utf-8
# ! author scq000

from pyrailgun import RailGun
import json
import sys
from encodingUtils import EncodingUtils

reload(sys)
sys.setdefaultencoding('utf8')

encodingUtils = EncodingUtils()
railgun = RailGun(encodingUtils)
railgun.setTask(file("sites.json"))
railgun.fire()
nodes = railgun.getShells('default')

file = file("result.txt", "w+")
for item in nodes:
    node = nodes[item]
    # print node
    file.write(node.get('name', [""])[0] + "\r\n")
    file.write(node.get('src', [""])[0] + "\r\n")
    file.write(node.get('magnet', [""])[0] + "\r\n")
    file.write(node.get('thunder', [""])[0] + "\r\n")
    file.write(node.get('size', [""])[0] + "\r\n")
    file.write(
        node.get('updateTime', [""])[0] +
        "\r\n====================================\n")