ruby on rails - rescue Nokogiri error -


I have a simple script that looks for the Twitter username and I get the location. But some usernames are not present and I get an error:

  /usr/lib/ruby/1.8/open-uri.rbaxy77:in 'open_http': 404 Not Found (OpenURI :: HTTPError)  

I have tried to defend it, but I can not do it to work Can anyone help? Thanks

a = [] my_file = File.new ("location.txt", 'a +') File.open ('address.txt', 'r') f | F | Whereas line = f.gets url = "http://twitter.com/#{line}" doc = Nokogiri :: HTML (open (url, 'user-agent' => 'ruby')) doc.css ("#side #profile"). Do each. Location | My_file.puts "http://twitter.com/#{line} # {loc.at_css (" .adr ").}}" Line and End is called

me too Need help to save another error:

  twitter.rb: 14: Undefined method for `zero ': NilClass (NoMethodError)  

Thanks.

Double quote inside second double quotation marks! Use single quotes for calls at at_css:

  my_file.puts "http://twitter.com/#{line} # {loc.at_css ('. Adr'). } " 

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -