Skip to content

Instantly share code, notes, and snippets.

@tomoyamkung
Created October 10, 2012 13:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoyamkung/3865716 to your computer and use it in GitHub Desktop.
Save tomoyamkung/3865716 to your computer and use it in GitHub Desktop.
[Ruby]Mechanize を使って a タグの href を取得するスニペット
require 'mechanize'
agent = Mechanize.new
agent.get('http://hogehoge.com')
agent.page.at("a").attributes["href"].text
# at は一致した最初の要素を返す
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment