Skip to content

Instantly share code, notes, and snippets.

@Sinceretear
Last active August 29, 2015 13:57
Show Gist options
  • Save Sinceretear/9730777 to your computer and use it in GitHub Desktop.
Save Sinceretear/9730777 to your computer and use it in GitHub Desktop.
mechanize practice
class MainController < ApplicationController
require 'rubygems'
require 'mechanize'
require 'open-uri'
def home
end
def datapages
url = 'http://www.hotnewhiphop.com/archive/'
agent = Mechanize.new
page = agent.get(url)
@hnhh = page.links.each do |link|
puts link
end
end
end
#the code for the view minues a lot of irrelevant stuff
<div>
<%= @hnhh.first.href %>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment