#README
#description ** do something evil as you want to **
- login with your account via any web brower
- use some tools to get your cookies
- pastie the cookies string into scripts
- run script in this format
command from_uid to_uid
- done
#!/usr/bin/env ruby | |
# @auther xhan | |
# @date sep19, 2010 | |
# @website http://ixhan.com | |
require 'net/http' | |
require 'net/https' | |
require 'rubygems' | |
require 'json' | |
def follow! | |
# puts "usage: from_id to_id(not included)" and return unless ARGV.count == 2 #why not works? | |
if ARGV.count != 2 | |
puts "usage: from_id to_id(not included)" | |
return | |
end | |
from,to = ARGV | |
from,to = from.to_i,to = to.to_i - 1 | |
total = to - from + 1 | |
puts "wrong argus" and return if total < 0 | |
puts "=== Task starts at duration [#{from},#{to}]" | |
http = Net::HTTP.new('t.baidu.com') | |
path = '/follow/setfollow?rn=56.392819142620596' | |
headers = { | |
'Cookie' => "YOUR COOKIES HERE", | |
'Referer' => 'http://t.baidu.com/', | |
'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' | |
# X-Request-By baidu.ajax | |
} | |
# {"status":-1,"msg":"已经关注了"} | |
# {"status":-1,"msg":"该用户不存在或者帐号异常"} | |
# status = 1 => success | |
successed = 0 | |
start_time = Time.now | |
(from..to).each do |uid| | |
data = "&uid=#{uid}&t=t" | |
resp, data = http.post(path, data, headers) | |
# puts 'Code = ' + resp.code + ' Msg = ' + resp.message | |
# resp.each {|key, val| puts key + ' = ' + val} | |
puts "uid #{uid}: data:#{data}" | |
json = JSON.parse(data) | |
successed += 1 if json['status'].to_i == 1 | |
end | |
end_time = Time.now | |
puts "=== Task finished ==============" | |
puts "time: #{end_time-start_time}" | |
puts "followed:#{successed}" | |
puts "failed:#{total - successed}" | |
puts "================================" | |
end | |
follow! |