匿名 #4899(2007/12/20 10:55 GMT) [ Ruby ] Rating1/1=1.00
WWW::Mechanizeで.
うちの環境では,timeout 1秒だと成功するorzので,0.1秒にしました.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/usr/local/bin/ruby require 'rubygems' require 'mechanize' class Crawler < WWW::Mechanize attr_accessor :agent PROXY_HOST = 'localhost' PROXY_PORT = '8080' URI = 'http://ja.doukaku.org/feeds/comments/' def initialize(conf = {}) super() self.max_history = 1 # 幸せになるおまじない self.set_proxy(PROXY_HOST, PROXY_PORT) conf.each {|method, value| self.send(method, value) } end def fetch get(URI) end end # puts Crawler.new.fetch.body # => succeed puts Crawler.new({:open_timeout= => 0.1, :read_timeout= => 0.1}).fetch.body
Rating1/1=1.00-0+
1 reply [ reply ]
ihag #4900(2007/12/20 11:42 GMT) Rating0/0=0.00
う,ログインし忘れてた.
[ reply ]
匿名
#4899()
[
Ruby
]
Rating1/1=1.00
WWW::Mechanizeで.
うちの環境では,timeout 1秒だと成功するorzので,0.1秒にしました.
Rating1/1=1.00-0+
1 reply [ reply ]