title: Parsing multiple URLs with Nokogiri?
body: <p>I am trying to get a list of hrefs from a list of ten URLs and running into trouble. </p>
  
  <p>Each of these blocks work separately from each other, but, when I try to combine them, I get a list of pages 1-10 and an error. What is the proper way to go about this?</p>
  
  <pre><code>#!/usr/bin/env ruby
  
  require 'rubygems'
  require 'nokogiri'
  require 'open-uri'
  
  #/ this prints all 10 of the URLs to pull page hrefs from.
  
  1.upto(10) do |pagenum|
  url = "http://www.mywebsite.com/page/#{pagenum}"
    puts url
  end
  
  #/ Prints out all of the hrefs. 
  
  doc = Nokogiri::HTML(open(url))
  doc.xpath('//h2/a/@href').each do |node|
    puts node.text
  end
  </code></pre>