ruby2ch 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +1 -0
- data/lib/ruby2ch/news.rb +45 -0
- data/lib/ruby2ch/thre.rb +34 -0
- data/lib/ruby2ch/version.rb +3 -0
- data/lib/ruby2ch.rb +10 -0
- data/ruby2ch.gemspec +25 -0
- metadata +54 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/ruby2ch/news.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#encoding: utf-8
|
3
|
+
require "mechanize"
|
4
|
+
require "time"
|
5
|
+
require "ruby2ch/thre"
|
6
|
+
#hogehoge
|
7
|
+
#hugahuga
|
8
|
+
agent = Mechanize.new
|
9
|
+
page = agent.get("http://uni.2ch.net/news/subback.html")
|
10
|
+
array = page.links.map{|link| link.href}
|
11
|
+
array2 = array.map{|link| link.split("/")[0]}
|
12
|
+
url = array2.map{|link| "http://uni.2ch.net/test/read.cgi/news/"+link}
|
13
|
+
|
14
|
+
p url.size
|
15
|
+
list = []
|
16
|
+
20.times{|i|
|
17
|
+
#page2 = agent.get(url[i])
|
18
|
+
|
19
|
+
t = Thre.new(url[i])
|
20
|
+
p t.title
|
21
|
+
p t.impetus
|
22
|
+
|
23
|
+
|
24
|
+
=begin
|
25
|
+
(name.size-1).times{|i|
|
26
|
+
print no[j] + " "
|
27
|
+
print hn[j] + " "
|
28
|
+
print date[j] + " " + time[j] + " "
|
29
|
+
print id[j]
|
30
|
+
print "\n"
|
31
|
+
print res[j]
|
32
|
+
print "\n\n"
|
33
|
+
}
|
34
|
+
=end
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
#勢い順にソート
|
39
|
+
list.sort!
|
40
|
+
list.reverse!
|
41
|
+
(list.size-1).times{|i|
|
42
|
+
print list[i][0].to_s + " " + list[i][1]
|
43
|
+
print "\n"
|
44
|
+
}
|
45
|
+
|
data/lib/ruby2ch/thre.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'mechanize'
|
3
|
+
|
4
|
+
module Ruby2ch
|
5
|
+
class Thre
|
6
|
+
def initialize(url)
|
7
|
+
@agent = Mechanize.new
|
8
|
+
@page = @agent.get(url)
|
9
|
+
@title = (@page/"h1").text
|
10
|
+
@res = (@page/"dd").map{|r| r.text}
|
11
|
+
@name = (@page/"dt").map{|n| n.text}
|
12
|
+
@name.map!{|nn| nn.split(":")}
|
13
|
+
@no = @name.map{|n| n[0]}
|
14
|
+
@hn = @name.map{|n| n[1]}
|
15
|
+
name_split = @name.map{|n| n[2].split(" ")}
|
16
|
+
@id = name_split.map{|n| n[2]}
|
17
|
+
@date1 = name_split.map{|n| n[0]}.map{|n| n.sub(/\(.\)/,"")}
|
18
|
+
@time = name_split.map{|n| n[1]}
|
19
|
+
@date = @date1[0] + " " + @time[0]
|
20
|
+
end
|
21
|
+
|
22
|
+
def impetus
|
23
|
+
return @res.size/(Time.now - Time.parse(@date)) * 60 * 60 * 24
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :title, :date
|
27
|
+
end
|
28
|
+
end
|
29
|
+
=begin
|
30
|
+
t = Thre.new("http://uni.2ch.net/test/read.cgi/newsplus/1321950691/")
|
31
|
+
puts t.title
|
32
|
+
puts t.date
|
33
|
+
puts t.impetus
|
34
|
+
=end
|
data/lib/ruby2ch.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require "ruby2ch/version"
|
5
|
+
require "ruby2ch/thre"
|
6
|
+
include Ruby2ch
|
7
|
+
#module Ruby2ch
|
8
|
+
# Your code goes here...
|
9
|
+
|
10
|
+
#end
|
data/ruby2ch.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
require "ruby2ch/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "ruby2ch"
|
8
|
+
s.version = Ruby2ch::VERSION
|
9
|
+
s.authors = ["Daichi ONODERA"]
|
10
|
+
s.email = ["onodes@onod.es"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{2ch for ruby}
|
13
|
+
s.description = %q{2ch for ruby}
|
14
|
+
|
15
|
+
s.rubyforge_project = "ruby2ch"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
# specify any dependencies here; for example:
|
23
|
+
# s.add_development_dependency "rspec"
|
24
|
+
# s.add_runtime_dependency "rest-client"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby2ch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daichi ONODERA
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-22 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: 2ch for ruby
|
15
|
+
email:
|
16
|
+
- onodes@onod.es
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- README
|
24
|
+
- Rakefile
|
25
|
+
- lib/ruby2ch.rb
|
26
|
+
- lib/ruby2ch/news.rb
|
27
|
+
- lib/ruby2ch/thre.rb
|
28
|
+
- lib/ruby2ch/version.rb
|
29
|
+
- ruby2ch.gemspec
|
30
|
+
homepage: ''
|
31
|
+
licenses: []
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project: ruby2ch
|
50
|
+
rubygems_version: 1.8.10
|
51
|
+
signing_key:
|
52
|
+
specification_version: 3
|
53
|
+
summary: 2ch for ruby
|
54
|
+
test_files: []
|