Help us understand the problem. What is going on with this article?

カスペルスキーのサイトからウィルスレベルをスクレイピングして、つぶやく。

More than 5 years have passed since last update.

Gem::Tiwtter、Gem::Mechanize必須。

kaspersky.rb
#! /usr/bin/ruby -Ku

#require 'kconv'
#require 'oauth'
require 'rubygems'
require 'mechanize'
require 'twitter'
require 'date'

date = Time.now.strftime("%H:%M:%S").to_s

agent = Mechanize::new
agent.user_agent_alias = "Windows IE 9"

agent.get('http://www.securelist.com/en/')  
agent.page.encoding = "EUC-JP"

activity = agent.page.search('span.m').to_s
activity = activity.scan(/Internet threat level:../)

threat_level = activity[0].split(' ')

case threat_level[3]
when "1"
 message = "[Threat level 1] The Internet threat alert status is currently normal."
when "2"
 message = "[Threat level 2] The Internet threat alert status is currently raised."
when "3"
 message = "[Threat level 3] The Internet threat alert status is currently high."
when "4"
 message = "[Threat level 4] The Internet threat alert status is currently critical.(http://www.securelist.com/en/)"
else
 message = "kaspersky_bot is busy..."
end

oauth = Twitter::OAuth.new('consumer token', 'consumer secret')
oauth.authorize_from_access('access token', 'access secret')

client = Twitter::Base.new(oauth)
client.update(date + message)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away