• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscaphegui翻訳comegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

Commit MetaInfo

Revision9a007e3b9d49ea34459dd2f226539a4395475178 (tree)
Zeit2009-01-15 00:17:42
Autorikeji <ikeji@f836...>
Commiterikeji

Log Message

Import new plugin.
- Feed::mixi::new_echo
- Feed::mixi::get_echo_list
- Publish::mixi::echo

Thx big-eyed-hamster.
http://d.hatena.ne.jp/big-eyed-hamster/20090113

git-svn-id: http://dev.ikejima.org/src/svn/pragger/trunk@396 f8368ae4-1e99-dc11-9799-0018f35ab5fa

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/plugin/Feed/mixi/get_echo_list.rb
@@ -0,0 +1,55 @@
1+## Feed::mixi::get_echo plugin -- by big-eyed-hamster
2+##
3+## http://d.hatena.ne.jp/big-eyed-hamster/20090113
4+##
5+## sample
6+## - module: Feed::mixi::new_echo
7+## - module: RSS::save
8+## config:
9+## filename: output.rdf
10+## title: mixi echo
11+##
12+
13+begin
14+ require 'kconv'
15+ require 'rubygems'
16+ require 'mechanize'
17+ require 'logger'
18+rescue LoadError
19+end
20+
21+def get_echo_list( config, data )
22+ username = $reg['mixi']['username']
23+ password = $reg['mixi']['password']
24+
25+ agent = WWW::Mechanize.new
26+ page = agent.get( 'http://mixi.jp/' )
27+ form = page.forms[0]
28+ form.fields.find { |f| f.name == 'email' }.value = username
29+ form.fields.find { |f| f.name == 'password' }.value = password
30+ form.fields.find { |f| f.name == 'next_url' }.value = "/home.pl"
31+ page = agent.submit( form, form.buttons.first )
32+
33+ contents = []
34+
35+ data << config['id'].to_s if config['id']
36+ data.each do |id|
37+ html = agent.get("http://mixi.jp/list_echo.pl?id=#{id}").root
38+ html.search("div.archiveList").each do |div|
39+ div.search("tr").each do |tr|
40+ contents << [
41+ tr.search("div")[0].inner_html, # id
42+ tr.search("div")[2].inner_html, # nickname
43+ tr.search("td.comment")[0].inner_html.gsub(
44+ /<span.*$/m,"").gsub(/<.*?>/,"").gsub(/\n+/,"\n") , # comment
45+ tr.search("div")[1].inner_html, # datetime
46+ ]
47+ end
48+ end
49+ end
50+
51+ echo_item = Struct.new(:title,:description,:link)
52+ return contents.map{|c| echo_item.new( c[1], c[2],"http://mixi.jp/list_echo.pl?id=#{c[0]}##{c[3]}" )}
53+end
54+
55+
--- /dev/null
+++ b/plugin/Feed/mixi/new_echo.rb
@@ -0,0 +1,51 @@
1+## Feed::mixi::get_echo plugin -- by big-eyed-hamster
2+##
3+## http://d.hatena.ne.jp/big-eyed-hamster/20090113
4+##
5+## sample
6+## - module: Feed::mixi::new_echo
7+## - module: RSS::save
8+## config:
9+## filename: output.rdf
10+## title: mixi echo
11+##
12+
13+begin
14+ require 'kconv'
15+ require 'rubygems'
16+ require 'mechanize'
17+ require 'logger'
18+rescue LoadError
19+end
20+
21+def new_echo( config, data )
22+ username = $reg['mixi']['username']
23+ password = $reg['mixi']['password']
24+
25+ agent = WWW::Mechanize.new
26+ page = agent.get( 'http://mixi.jp/' )
27+ form = page.forms[0]
28+ form.fields.find { |f| f.name == 'email' }.value = username
29+ form.fields.find { |f| f.name == 'password' }.value = password
30+ form.fields.find { |f| f.name == 'next_url' }.value = "/home.pl"
31+ page = agent.submit( form, form.buttons.first )
32+
33+ contents = []
34+ html = agent.get("http://mixi.jp/recent_echo.pl").root
35+ html.search("div.archiveList").each do |div|
36+ div.search("tr").each do |tr|
37+ contents << [
38+ tr.search("div")[0].inner_html, # id
39+ tr.search("div")[2].inner_html, # nickname
40+ tr.search("td.comment")[0].inner_html.gsub(
41+ /<span.*$/m,"").gsub(/<.*?>/,"").gsub(/\n+/,"\n") , # comment
42+ tr.search("div")[1].inner_html, # datetime
43+ ]
44+ end
45+ end
46+
47+ echo_item = Struct.new(:title,:description,:link)
48+ return contents.map{|c| echo_item.new( c[1], c[2],"http://mixi.jp/list_echo.pl?id=#{c[0]}##{c[3]}" )}
49+end
50+
51+
--- /dev/null
+++ b/plugin/Publish/mixi/echo.rb
@@ -0,0 +1,39 @@
1+## Publish::mixi::echo -- by big-eyed-hamster
2+## pragger plugin to post mixi echo
3+##
4+## http://d.hatena.ne.jp/big-eyed-hamster/20090114
5+##
6+##
7+## - module: const_list
8+## config:
9+## - test_dayo
10+## - module: Publish::mixi::echo
11+##
12+
13+begin
14+ require 'kconv'
15+ require 'rubygems'
16+ require 'mechanize'
17+ require 'logger'
18+rescue LoadError
19+end
20+
21+def echo( config, data )
22+ username = $reg['mixi']['username']
23+ password = $reg['mixi']['password']
24+
25+ agent = WWW::Mechanize.new
26+ page = agent.get( 'http://mixi.jp/' )
27+ form = page.forms[0]
28+ form.fields.find { |f| f.name == 'email' }.value = username
29+ form.fields.find { |f| f.name == 'password' }.value = password
30+ form.fields.find { |f| f.name == 'next_url' }.value = "/home.pl"
31+ page = agent.submit( form, form.buttons.first )
32+
33+ page = agent.get( 'http://mixi.jp/recent_echo.pl' )
34+
35+ form = page.forms[1]
36+ form.fields.find { |f| f.name == 'body' }.value = data.to_s.toeuc
37+ agent.submit( form,form.buttons.first )
38+end
39+