6 시간과 같은 일정 간격으로 RSS를 폴링하는 방법에 대한 조언을 구합니다.6 시간마다 RSS를 폴링하는 레일
다음 코드가 작동하면 피드를 읽고 구문 분석하여 데이터베이스에 추가합니다. 새로운 피드 만 추가합니다. 다음은 클래스 메소드입니다.
def self.update_from_feed(feed_url)
feed = Feedzirra::Feed.fetch_and_parse("http://feeds.feedburner.com/PaulDixExplainsNothing") #Example feed
feed.entries.each do |entry|
unless exists? :guid => entry.id
create!(
:name => entry.title,
:url => entry.url,
:published_at => entry.published,
:guid => entry.id
)
end
end
end
6 시간마다 어떻게이 전체 클래스 메소드를 실행할 수 있습니까? Ruby (및 Rails)에 익숙하지 않으므로 예제를 통해 도움을 얻을 수 있습니다. 가능한 경우 외부 cron 작업을 실행하지 마십시오. 코드 내에서 6 시간마다 실행하기를 원합니다. 감사합니다.
가능한 [레일 용 크론 작업 : 모범 사례?] (http://stackoverflow.com/questions/285717/a-cron-job-for-rails-best-practices) –