title: Ruby - Opening absolute url from relative
body: <p>I've built a web scraper ruby script using open-uri and nokogiri, I'm pretty new to it all but it's all working for a couple of the websites I need to extract data from that have full URL's in the source, apart from one which uses relative URL's. </p>
  
  <p>What the script does, is opens the page, builds an array of pages to open then goes through and extracts the data from the css (not xpath). </p>
  
  <p>How do I force the script to use full URL's in the instance where they're relative, it's been bugging me for a while and I can't seem to get it running</p>
  
  <p>In my case, I think I need to add something at the point it pushes the URL's, could anyone please point me in the right direction? It would be hugely appreciated! Thanks!</p>
  
  <pre><code>require 'open-uri'
  require 'nokogiri'
  
  PAGE_URL = "http://www.OMMITED.co.uk"
  
  page = Nokogiri::HTML(open(PAGE_URL, "User-Agent" =&gt; “OMMITED“))
  
  links = page.css("a")
  
  links_array = Array.new
  
  links.each{|link|
          url = link['href'].nil? ? 'empty' : link['href']
          if url.include? 'category'  and !url.include? '/all'
                  links_array.push url
          end
  }
  </code></pre>