crawler update

This commit is contained in:
Andreas Stephanides
2015-05-04 13:41:07 +02:00
parent a2491ee84d
commit e16762fdd0
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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