Merge branch 'master' of github.com:fetsite/fetsite

This commit is contained in:
Andreas Stephanides
2015-05-13 15:09:34 +02:00
6 changed files with 15 additions and 10 deletions

View File

@@ -112,18 +112,18 @@ class Crawlobject < ActiveRecord::Base
def json
JSON.parse(self.raw)
end
def self.crawl_news
def self.crawl_news(id)
cfg = Rails.application.config
res = JSON.parse(`python #{Rails.root}/bin/#{cfg.crawlconfig[5]['bin']} #{cfg.crawlconfig[5]['url']}`)
res = JSON.parse(`python #{Rails.root}/bin/#{cfg.crawlconfig[id]['bin']} #{cfg.crawlconfig[id]['url']}`)
res.each do |r|
cc=Crawlobject.new(:raw=>r.to_json)
cc.objtype=5
cc.objtype=id
cc.parse_object
cc.calc_hash
if Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>5).count==0
if Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>id).count==0
cc.save
else
cc = Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>5).first
cc = Crawlobject.where(:objhash2=>cc.objhash2, :objtype=>id).first
cc.raw=r.to_json
cc.parse_object
cc.calc_hash

View File

@@ -262,7 +262,7 @@ class Lva < ActiveRecord::Base
def read_et_forum
lva=self
url=lva.forumlink
ans = JSON.parse(`python ../microdata/downloadlogin.py #{url}`)
ans = JSON.parse(`python #{Rails.root}/bin/downloadlogin.py #{url}`)
ans.each do |a|
if Crawlobject.where(:objhash=>Digest::SHA512.hexdigest(a.to_json), :objtype=>1).count ==0
aa = Crawlobject.new(:raw=>a.to_json)