SlideShare una empresa de Scribd logo
1 de 36
Mechanize
Ruby
@Sixeight
Ruby
Machanize

Google
photo by km6xo



Mechanize   automating interaction with websites.
WWW::Mechanize
WWW::Mechanize
•Ruby
WWW::Mechanize
•Ruby

 •Web
WWW::Mechanize
•Ruby

 •Web

 •Cookies
WWW::Mechanize
•Ruby

 •Web

 •Cookies

 •
WWW::Mechanize
•Ruby

 •Web

 •Cookies

 •

 •      Ruby
sudo gem install mechanize
agent = WWW::Mechanize.new
agent = WWW::Mechanize.new
agent = WWW::Mechanize.new
agent.get ‘http://google.com’
REST { GET, POST, PUT, DELETE }



agent.get ‘http://google.com’
REST { GET, POST, PUT, DELETE }



agent.get ‘http://google.com’
REST { GET, POST, PUT, DELETE }



agent.get ‘http://google.com’
REST { GET, POST, PUT, DELETE }



agent.get ‘http://google.com’
agent.page
#<WWW::Mechanize::Page
              {url #<URI::HTTP:0x101f39ab0 URL:http://www.goo
              {meta}
              {title "Google"}
              {iframes}
              {frames}
              {links
               #<WWW::Mechanize::Page::Link
                "347224273345203217"
                "http://images.google.co.jp/imghp?hl=ja&tab=wi">
               #<WWW::Mechanize::Page::Link
                "345213225347224273"
                "http://video.google.co.jp/?hl=ja&tab=wv">
               #<WWW::Mechanize::Page::Link
                "345234260345233263"
                "http://maps.google.co.jp/maps?hl=ja&tab=wl">


agent.page     #<WWW::Mechanize::Page::Link
                "34320321334320324534320327434320
                "http://news.google.co.jp/nwshp?hl=ja&tab=wn">
               #<WWW::Mechanize::Page::Link
                "346233270347261215"
                "http://books.google.co.jp/bkshp?hl=ja&tab=wp">
               #<WWW::Mechanize::Page::Link
                "Gmail"
                "http://mail.google.com/mail/?hl=ja&tab=wm">
               #<WWW::Mechanize::Page::Link
                "343201235343201256344273226 30227
                "http://www.google.co.jp/intl/ja/options/">
               #<WWW::Mechanize::Page::Link
                "iGoogle"
                "/url?sa=p&pref=ig&pval=3&q=http://www.google.c
             %3Diglk&usg=AFQjCNEmQuNg1ivauCid9lXp5yYSx6
               #<WWW::Mechanize::Page::Link
                "34624423434726424235025025534525
Google
require 'rubygems'
require 'mechanize'

agent = WWW::Mechanize.new
agent.get 'http://google.com'
agent.page.form_with(:name => 'f') do |f|
  f.field_with(:name => 'q').value = 'Ruby'
  f.click_button
end
puts agent.page.search('//h3').map(&:content)
agent.page.form_with(:name => 'f') do |f|
  f.field_with(:name => 'q').value = 'Ruby'
  f.click_button
end
•                                  Ruby
•   Ruby Programming Language
•   Ruby - Wikipedia
•         Ruby -      Ruby
•   Ruby       -
•       Ruby          Wiki -    Ruby      Wiki
•   RDE(Ruby Development Environment) - Ruby
•   Ruby Annotation
•   Ruby      63                                  −   IT


•                                Ruby     ITpro
•   Ruby
Ruby

Más contenido relacionado

La actualidad más candente

Future of Web Development
Future of Web DevelopmentFuture of Web Development
Future of Web DevelopmentZeno Rocha
 
Simple Web Apps With Sinatra
Simple Web Apps With SinatraSimple Web Apps With Sinatra
Simple Web Apps With Sinatraa_l
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With CucumberSean Cribbs
 
Testiranje s capybaro
Testiranje s capybaroTestiranje s capybaro
Testiranje s capybaroArto Artnik
 
Building A Mini Google High Performance Computing In Ruby
Building A Mini Google  High Performance Computing In RubyBuilding A Mini Google  High Performance Computing In Ruby
Building A Mini Google High Performance Computing In Rubyrailsconf
 
Liferay + Wearables
Liferay + WearablesLiferay + Wearables
Liferay + WearablesZeno Rocha
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in RubyIlya Grigorik
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...Ho Chi Minh City Software Testing Club
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behatimoneytech
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
Web Components: What, Why, How, and When
Web Components: What, Why, How, and WhenWeb Components: What, Why, How, and When
Web Components: What, Why, How, and WhenPeter Gasston
 
J Query - Your First Steps
J Query - Your First StepsJ Query - Your First Steps
J Query - Your First StepsBronson Quick
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to JqueryAmzad Hossain
 

La actualidad más candente (17)

Future of Web Development
Future of Web DevelopmentFuture of Web Development
Future of Web Development
 
Simple Web Apps With Sinatra
Simple Web Apps With SinatraSimple Web Apps With Sinatra
Simple Web Apps With Sinatra
 
Routes
RoutesRoutes
Routes
 
Intro to Rails
Intro to RailsIntro to Rails
Intro to Rails
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Testiranje s capybaro
Testiranje s capybaroTestiranje s capybaro
Testiranje s capybaro
 
Building A Mini Google High Performance Computing In Ruby
Building A Mini Google  High Performance Computing In RubyBuilding A Mini Google  High Performance Computing In Ruby
Building A Mini Google High Performance Computing In Ruby
 
Liferay + Wearables
Liferay + WearablesLiferay + Wearables
Liferay + Wearables
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in Ruby
 
Performance
PerformancePerformance
Performance
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Web Components: What, Why, How, and When
Web Components: What, Why, How, and WhenWeb Components: What, Why, How, and When
Web Components: What, Why, How, and When
 
J Query - Your First Steps
J Query - Your First StepsJ Query - Your First Steps
J Query - Your First Steps
 
Mastering Grunt
Mastering GruntMastering Grunt
Mastering Grunt
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 

Destacado (7)

Sinatra事始め
Sinatra事始めSinatra事始め
Sinatra事始め
 
Vim Text Object
Vim Text ObjectVim Text Object
Vim Text Object
 
2009年ふりかえり
2009年ふりかえり2009年ふりかえり
2009年ふりかえり
 
Fats lecture final
Fats lecture finalFats lecture final
Fats lecture final
 
Rubyで始めるGTD
Rubyで始めるGTDRubyで始めるGTD
Rubyで始めるGTD
 
Where's ITEC
Where's ITECWhere's ITEC
Where's ITEC
 
KPTのすすめ
KPTのすすめKPTのすすめ
KPTのすすめ
 

Similar a It's Mechanize for it. Ruby as a Finder.

Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyFabio Akita
 
A web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentationA web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentationJustin Dorfman
 
Using ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on RailsUsing ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on RailsDave Bouwman
 
Log files: The Overlooked Source of SEO Opportunities
Log files: The Overlooked Source of SEO OpportunitiesLog files: The Overlooked Source of SEO Opportunities
Log files: The Overlooked Source of SEO OpportunitiesRobin Rozhon
 
Integration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + SeleniumIntegration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + Seleniumtka
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Nicholas Zakas
 
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)Nicholas Zakas
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFabio Akita
 
10 Things Web Designers tend to forget when doing SEO
10 Things Web Designers tend to forget when doing SEO10 Things Web Designers tend to forget when doing SEO
10 Things Web Designers tend to forget when doing SEOTimon Hartung
 
Google-image poisoning: How hackers use images to spread malware
Google-image poisoning: How hackers use images to spread malwareGoogle-image poisoning: How hackers use images to spread malware
Google-image poisoning: How hackers use images to spread malwareAvast
 
Design+Performance Velocity 2015
Design+Performance Velocity 2015Design+Performance Velocity 2015
Design+Performance Velocity 2015Steve Souders
 
Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表byron zhao
 
Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表byron zhao
 
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Rhio Kim
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)True-Vision
 
mastodon API
mastodon APImastodon API
mastodon APItreby
 

Similar a It's Mechanize for it. Ruby as a Finder. (20)

Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com RubyConsegi 2010 - Dicas de Desenvolvimento Web com Ruby
Consegi 2010 - Dicas de Desenvolvimento Web com Ruby
 
A web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentationA web perf dashboard up & running in 90 minutes presentation
A web perf dashboard up & running in 90 minutes presentation
 
Using ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on RailsUsing ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on Rails
 
Log files: The Overlooked Source of SEO Opportunities
Log files: The Overlooked Source of SEO OpportunitiesLog files: The Overlooked Source of SEO Opportunities
Log files: The Overlooked Source of SEO Opportunities
 
Integration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + SeleniumIntegration Test Cucumber + Webrat + Selenium
Integration Test Cucumber + Webrat + Selenium
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)
 
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
 
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com RubyFisl 11 - Dicas de Desenvolvimento Web com Ruby
Fisl 11 - Dicas de Desenvolvimento Web com Ruby
 
10 Things Web Designers tend to forget when doing SEO
10 Things Web Designers tend to forget when doing SEO10 Things Web Designers tend to forget when doing SEO
10 Things Web Designers tend to forget when doing SEO
 
Ruby Kaigi 2008 LT
Ruby Kaigi 2008 LTRuby Kaigi 2008 LT
Ruby Kaigi 2008 LT
 
Google-image poisoning: How hackers use images to spread malware
Google-image poisoning: How hackers use images to spread malwareGoogle-image poisoning: How hackers use images to spread malware
Google-image poisoning: How hackers use images to spread malware
 
ApacheCon 2005
ApacheCon 2005ApacheCon 2005
ApacheCon 2005
 
Design+Performance Velocity 2015
Design+Performance Velocity 2015Design+Performance Velocity 2015
Design+Performance Velocity 2015
 
Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表
 
Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表Google和各种网站的IPv6服务hosts列表
Google和各种网站的IPv6服务hosts列表
 
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
Node.js 기반 정적 페이지 블로그 엔진, 하루프레스
 
Ruby Robots
Ruby RobotsRuby Robots
Ruby Robots
 
Sprockets
SprocketsSprockets
Sprockets
 
Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
 
mastodon API
mastodon APImastodon API
mastodon API
 

Más de Tomohiro Nishimura

逃げ道をなくすということについて、僕の持っている知見を話します。
逃げ道をなくすということについて、僕の持っている知見を話します。逃げ道をなくすということについて、僕の持っている知見を話します。
逃げ道をなくすということについて、僕の持っている知見を話します。Tomohiro Nishimura
 
シュッとふりかえる Ruby 2.0 以降
シュッとふりかえる Ruby 2.0 以降シュッとふりかえる Ruby 2.0 以降
シュッとふりかえる Ruby 2.0 以降Tomohiro Nishimura
 
DSLについて語るときに僕の語ること
DSLについて語るときに僕の語ることDSLについて語るときに僕の語ること
DSLについて語るときに僕の語ることTomohiro Nishimura
 
Rubyist のための HTML5 入門 -Content Models-
Rubyist のための HTML5 入門 -Content Models-Rubyist のための HTML5 入門 -Content Models-
Rubyist のための HTML5 入門 -Content Models-Tomohiro Nishimura
 
NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法Tomohiro Nishimura
 
Haml/Sassを使って履歴書を書くためのn個の方法
Haml/Sassを使って履歴書を書くためのn個の方法Haml/Sassを使って履歴書を書くためのn個の方法
Haml/Sassを使って履歴書を書くためのn個の方法Tomohiro Nishimura
 
RubyKaigi2009さんか報告会
RubyKaigi2009さんか報告会RubyKaigi2009さんか報告会
RubyKaigi2009さんか報告会Tomohiro Nishimura
 

Más de Tomohiro Nishimura (20)

逃げ道をなくすということについて、僕の持っている知見を話します。
逃げ道をなくすということについて、僕の持っている知見を話します。逃げ道をなくすということについて、僕の持っている知見を話します。
逃げ道をなくすということについて、僕の持っている知見を話します。
 
シュッとふりかえる Ruby 2.0 以降
シュッとふりかえる Ruby 2.0 以降シュッとふりかえる Ruby 2.0 以降
シュッとふりかえる Ruby 2.0 以降
 
DSLについて語るときに僕の語ること
DSLについて語るときに僕の語ることDSLについて語るときに僕の語ること
DSLについて語るときに僕の語ること
 
Atom ことはじめ
Atom ことはじめAtom ことはじめ
Atom ことはじめ
 
The way to the Kyoto.rb
The way to the Kyoto.rbThe way to the Kyoto.rb
The way to the Kyoto.rb
 
Kyotorb#4
Kyotorb#4Kyotorb#4
Kyotorb#4
 
Kyotorb#3
Kyotorb#3Kyotorb#3
Kyotorb#3
 
Kyotorb Meetup #2
Kyotorb Meetup #2Kyotorb Meetup #2
Kyotorb Meetup #2
 
Kyoto.rb
Kyoto.rbKyoto.rb
Kyoto.rb
 
2010年ふりかえる
2010年ふりかえる2010年ふりかえる
2010年ふりかえる
 
Rubyist のための HTML5 入門 -Content Models-
Rubyist のための HTML5 入門 -Content Models-Rubyist のための HTML5 入門 -Content Models-
Rubyist のための HTML5 入門 -Content Models-
 
NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法
 
Boys, do LiveCoding
Boys, do LiveCodingBoys, do LiveCoding
Boys, do LiveCoding
 
Introduce the LiveCoding
Introduce the LiveCodingIntroduce the LiveCoding
Introduce the LiveCoding
 
Lazyselect
LazyselectLazyselect
Lazyselect
 
Introduce the Hacobu
Introduce the HacobuIntroduce the Hacobu
Introduce the Hacobu
 
Introduce RSpec's Matchers
Introduce RSpec's MatchersIntroduce RSpec's Matchers
Introduce RSpec's Matchers
 
Termtter Refactoring Spa
Termtter Refactoring SpaTermtter Refactoring Spa
Termtter Refactoring Spa
 
Haml/Sassを使って履歴書を書くためのn個の方法
Haml/Sassを使って履歴書を書くためのn個の方法Haml/Sassを使って履歴書を書くためのn個の方法
Haml/Sassを使って履歴書を書くためのn個の方法
 
RubyKaigi2009さんか報告会
RubyKaigi2009さんか報告会RubyKaigi2009さんか報告会
RubyKaigi2009さんか報告会
 

It's Mechanize for it. Ruby as a Finder.