Created
September 17, 2010 01:17
-
-
Save soh335/583491 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mechanize' | |
require 'open-uri' | |
username = '' | |
password = '' | |
#Mechanizeの設定 | |
agent = Mechanize.new | |
agent.user_agent_alias = 'Mac Safari' | |
#ログイン処理 | |
page = agent.get('http://mixi.jp/') | |
form = page.forms[0] | |
form.fields.find {|f| f.name == 'email'}.value = username | |
form.fields.find {|f| f.name == 'password'}.value = password | |
form.fields.find {|f| f.name == 'next_url'}.value = '/home.pl' | |
results = agent.submit(form) | |
#対象コミュニティページのURL | |
url = ["http://mixi.jp/view_community.pl?id=1390708", | |
"http://mixi.jp/view_community.pl?id=657724", | |
"http://mixi.jp/view_community.pl?id=629852" | |
] | |
get_category = [] | |
url.each do |a| | |
agent.get(a).search('//dl[contains(concat(" ",@class," "), " categoryName ")]/dd').each do |b| | |
p b.text | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment