# 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")
# 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")
# User: princehaku # Date: 13-2-12 # Time: 1:01 # __author__ = 'haku' from pyrailgun import RailGun import os, sys, re, json, time import urllib import urllib2 import requests import logging reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() console = logging.FileHandler("bangumi.log") console.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') console.setFormatter(formatter) railgun.logger.addHandler(console) railgun.setTask(file("bangumi.json")) railgun.fire(); nodes = railgun.getShells() file = file("bangumi.demo.txt", "w+") def request_connnect(post, n=0): try: response = requests.Session().post(
# coding: UTF-8 # User: haku # Date: 13-2-12 # Time: 上午1:01 # __author__ = 'haku' from pyrailgun import RailGun import sys reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() railgun.setTask(file("webkit.json")); railgun.fire(); nodes = railgun.getShells() file = file("demo_webkit.txt", "w+") for id in nodes: node = nodes[id] file.write(node.get('content',[""])[0] + "\r\n====================================")
def getinfo(node_elem): # get fight chinese name repr(node_elem.decode('utf-8')) ret_name = re.findall(u'[\u4e00-\u9fa5]+', node_elem) ret_str = ''.join(ret_name) ret_n = ret_str.encode('gb2312') #get flght code name ret_code = re.findall(u'[A-Z0-9]+', node_elem) ret_c_tmp = ''.join(ret_code) ret_c = ret_c_tmp.encode('utf-8') #print ret_n,ret_c return ret_n, ret_c railgun = RailGun() railgun.setTask(file("config_webkit.json")) railgun.fire() nodes = railgun.getShells() file = file("flight_data.txt", "w+") for id in nodes: node = nodes[id] #file.write(str(node) + "\r\n") #str_name,str_code = getinfo(node.get('name',[""])[0]) #file.write(str_name + ':' + str_code + "\r\n") #file.write(node.get('content',[""])[0] + "\r\n") str_content = node.get('content', [""])[0] #print (str_content) soup_content = BeautifulSoup(str_content) #print (soup_content.find('div').div.string) print(soup_content.div.string)
# coding: UTF-8 # User: princehaku # Date: 13-2-12 # Time: 1:01 # __author__ = 'haku' from pyrailgun import RailGun import sys reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() railgun.setTask(file("basic.json")) railgun.addCustomAction() railgun.fire(); nodes = railgun.getShells() file = file("demo_basic.demo.txt", "w+") for id in nodes: node = nodes[id] file.write(node.get('score', [""])[0] + "\r\n") file.write(node.get('img', [""])[0] + "\r\n") file.write(node.get('description', [""])[0] + "\r\n====================================")
#! /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")
# coding: UTF-8 # User: princehaku # Date: 13-2-12 # Time: 1:01 # __author__ = 'haku' from pyrailgun import RailGun import sys reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() railgun.setTask(file("basic.json")) railgun.fire(); nodes = railgun.getShells() file = file("demo_basic.demo.txt", "w+") for id in nodes: node = nodes[id] file.write(node.get('score', [""])[0] + "\r\n") file.write(node.get('img', [""])[0] + "\r\n") file.write(node.get('description', [""])[0] + "\r\n====================================")
# coding: UTF-8 # User: princehaku # Date: 13-2-12 # Time: 1:01 # __author__ = "haku" from pyrailgun import RailGun import sys reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() railgun.setTask(file("basic.json")) railgun.fire() nodes = railgun.getShells() file = file("demo_basic.demo.txt", "w+") for id in nodes: node = nodes[id] file.write(node.get("score", [""])[0] + "\r\n") file.write(node.get("img", [""])[0] + "\r\n") file.write(node.get("description", [""])[0] + "\r\n====================================")
from pyrailgun import RailGun railgun = RailGun() railgun.setTask(file("testsite.json")); railgun.fire(); # nodes = railgun.getShells('default') # print nodes
# coding: UTF-8 # User: haku # Date: 13-2-12 # Time: 1:01 # __author__ = 'haku' from pyrailgun import RailGun import sys reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() railgun.setTask(file("basic.json")) railgun.addCustomAction() railgun.fire() nodes = railgun.getShells() file = file("demo_basic.txt", "w+") for id in nodes: node = nodes[id] file.write(node.get('score', [""])[0] + "\r\n") file.write(node.get('img', [""])[0] + "\r\n") file.write( node.get('description', [""])[0] + "\r\n====================================")
# coding: UTF-8 # User: haku # Date: 13-2-12 # Time: 上午1:01 # __author__ = 'haku' from pyrailgun import RailGun import sys reload(sys) sys.setdefaultencoding("utf-8") railgun = RailGun() railgun.setTask(file("basic.yaml")); railgun.fire(); nodes = railgun.getShells() file = file("demo_basic.txt", "w+") for id in nodes: node = nodes[id] file.write(node.get('score',[""])[0] + "\r\n") file.write(node.get('img',[""])[0] + "\r\n") file.write(node.get('description',[""])[0] + "\r\n====================================")