Created
October 10, 2012 13:41
-
-
Save tomoyamkung/3865716 to your computer and use it in GitHub Desktop.
[Ruby]Mechanize を使って a タグの href を取得するスニペット
This file contains 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 '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