do |author| f = File.new(author + ".txt",'w') 1.upto(100) do |page| urltext = "http://blog.moviefone.com/bloggers/#{author} " urltext << "/page/#{page.to_s}/" doc = Nokogiri::HTML(open(urltext)) doc.css('h2 > a').each do |a_tag| begin f.puts "===============================" f.puts a_tag.content f.puts a_tag['href'] doc2 = Nokogiri::HTML(open(a_tag['href'])) doc2.css('.post-body').each do |article| f.puts article.content end f.puts "===============================" rescue f.puts "ERROR DOWNLOADING:"+ a_tag['href'] end end end end Thursday, April 26, 2012