From: "Jesús Gabriel y Galán" Date: 2012-10-10T00:06:58+09:00 Subject: Re: reading and using urls from txtfile On Tue, Oct 9, 2012 at 4:51 PM, Sybren Kooistra wrote: > Hi all, > > I've been at this for a few hours now, and not getting much further: > > I want to read a bunch of urls, listed on each seperate line in a txt > file. > I then want to use these seperate urls and do a DO EACH method (a > nokogiri parse) for all these urls. > > What i'm trying now is: > > f = File.open("file.txt", "r") > f.each_line do |lijn| Better to use the block forms: File.foreach("file.txt") do |line| end This way the file is properly closed. > searchableurl = Nokogiri::HTML (lijn) That method receives the HTML string, not the URL. You need to read its contents first: require 'open-uri' Nokogiri::HTML(open(line)) Jesus.