now it actually scrapes some urls
This commit is contained in:
parent
c71a306e09
commit
b813682d13
2 changed files with 14 additions and 4 deletions
2
Gemfile
2
Gemfile
|
@ -4,3 +4,5 @@ gem "eventmachine"
|
|||
gem "em-irc"
|
||||
gem "logger"
|
||||
gem "nokogiri"
|
||||
gem "datamapper"
|
||||
gem "dm-postgres-adapter"
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
require 'open-uri'
|
||||
require 'digest/md5'
|
||||
|
||||
include EventMachine::IRC::Commands
|
||||
|
||||
Client.register_trigger("PRIVMSG") { |msg|
|
||||
message = msg[:params][1]
|
||||
|
||||
message.split { |word|
|
||||
puts word if word ~ /4cdn[.]org/
|
||||
msg[:params].each { |word|
|
||||
if word =~ /4cdn[.]org/ then
|
||||
ext = "." + word.sub(/.*[.]([^.]*)/, '\1') if word.match(/[^.]+[.][^.]+/)
|
||||
content = open(word).read
|
||||
md5 = Digest::MD5.hexdigest(content)
|
||||
File.open(Config[:scrape][:basepath] + md5 + ext, 'w') { |file|
|
||||
file.write(content)
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue