• 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

Revision07a8a9bb689cb7e81e5770eee15ec2246a5932e9 (tree)
Zeit2008-06-26 00:36:02
Autorikeji <ikeji@f836...>
Commiterikeji

Log Message

mixi reader

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

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/plugin/Feed/mixi/get_diary.rb
@@ -0,0 +1,60 @@
1+require 'kconv'
2+require 'rubygems'
3+require 'mechanize'
4+
5+def get_diary(config,data)
6+ username = $reg['mixi']['username']
7+ password = $reg['mixi']['password']
8+
9+ client = WWW::Mechanize.new
10+ page = client.get('http://mixi.jp/')
11+ sleep 5
12+ form = page.forms[0]
13+ form.fields.find {|f| f.name == 'email'}.value = username
14+ form.fields.find {|f| f.name == 'password'}.value = password
15+ form.fields.find {|f| f.name == 'next_url'}.value = '/home.pl'
16+ page = client.submit(form, form.buttons.first)
17+ sleep 5
18+
19+ if /url=([^"])"/ =~ page.body
20+ link = 'http://mixi.jp' + $1.to_s
21+ client.get(link)
22+ sleep 5
23+ end
24+
25+ data = data.map do|i|
26+ page = client.get(i)
27+ sleep 5
28+ MixiRSSItem.new(page,i)
29+ end
30+ return data
31+end
32+
33+class MixiRSSItem
34+ def initialize(page,url)
35+ @page = page
36+ @url = url
37+ end
38+ def title
39+ @page.title.toutf8
40+ end
41+ def link
42+ @url
43+ end
44+ def description
45+ if(@page.body =~ /\<\!\-\-\[viewDiaryBox\]\-\-\>(.*)\<\!\-\-\/viewDiaryBox\-\-\>/m)
46+ $1.toutf8
47+ end
48+ end
49+ def date
50+ if(@page.body =~ /(\d{2})年(\d{2})月(\d{2})日(\d{2}):(\d{2})/)
51+ p Time.new($1,$2,$3,$4,$5)
52+ Time.new($1,$2,$3,$4,$5)
53+ end
54+ end
55+
56+ def to_s
57+ title + ":" + link + ":" + description + ":" + date
58+ end
59+
60+end
--- /dev/null
+++ b/plugin/Feed/mixi/new_diary.rb
@@ -0,0 +1,34 @@
1+require 'rubygems'
2+require 'mechanize'
3+
4+def new_diary(config,data)
5+ username = $reg['mixi']['username']
6+ password = $reg['mixi']['password']
7+
8+ client = WWW::Mechanize.new
9+ page = client.get('http://mixi.jp/')
10+ sleep 5
11+ form = page.forms[0]
12+ form.fields.find {|f| f.name == 'email'}.value = username
13+ form.fields.find {|f| f.name == 'password'}.value = password
14+ form.fields.find {|f| f.name == 'next_url'}.value = '/home.pl'
15+ page = client.submit(form, form.buttons.first)
16+ sleep 5
17+
18+ if /url=([^"])"/ =~ page.body
19+ link = 'http://mixi.jp' + $1.to_s
20+ client.get(link)
21+ sleep 5
22+ end
23+
24+ data = []
25+ diarylist = client.get('http://mixi.jp/new_friend_diary.pl')
26+ sleep 5
27+ diarylist.links.each do |link|
28+ diaryurl = link.href # => 'view_diary.pl?id=12345&owner_id=2345'
29+ if /view_diary.pl\?id\=/ =~ diaryurl then
30+ data << 'http://mixi.jp/' + diaryurl
31+ end
32+ end
33+ return data
34+end