crawler update
This commit is contained in:
@@ -3,7 +3,7 @@ class CrawlerController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
authorize! :doadmin, User
|
authorize! :doadmin, User
|
||||||
|
|
||||||
@crawlobjs=Crawlobject.where(:objtype=>5)
|
@crawlobjs=Crawlobject.where(:objtype=>5).order(:published_at).reverse_order
|
||||||
end
|
end
|
||||||
def load_attachments
|
def load_attachments
|
||||||
authorize! :doadmin, User
|
authorize! :doadmin, User
|
||||||
|
|||||||
@@ -112,8 +112,9 @@ class Crawlobject < ActiveRecord::Base
|
|||||||
def json
|
def json
|
||||||
JSON.parse(self.raw)
|
JSON.parse(self.raw)
|
||||||
end
|
end
|
||||||
def self.crawl_htu
|
def self.crawl_news
|
||||||
res = JSON.parse(`python #{RAILS_ROOT}/bin/#{Rails.config.crawlconfig[5]['bin']} #{Rails.config.crawlconfig[5]['url']}`)
|
cfg = Rails.application.config
|
||||||
|
res = JSON.parse(`python #{Rails.root}/bin/#{cfg.crawlconfig[5]['bin']} #{cfg.crawlconfig[5]['url']}`)
|
||||||
res.each do |r|
|
res.each do |r|
|
||||||
cc=Crawlobject.new(:raw=>r.to_json)
|
cc=Crawlobject.new(:raw=>r.to_json)
|
||||||
cc.objtype=5
|
cc.objtype=5
|
||||||
|
|||||||
Reference in New Issue
Block a user