Ruby HTTPNotFound Error with Mechanize -


i have ruby on rails application trying access various links on yahoo sports , when tries reach page, gives me error below. error consistent , of links fails on, fails on. not case of work , don't. find though page exist , loads fine, i'm not sure why giving me error. has experienced type of behavior before , if so, have suggestions on how work?

404 => net::httpnotfound http://sports.yahoo.com/mlb/players/9893/ -- unhandled response

@client = mechanize.new() @client.request_headers = { "accept-encoding" => "" } @client.ignore_bad_chunking = true  #works #url = 'http://sports.yahoo.com/mlb/players/7307'  #doesn't work url = 'http://sports.yahoo.com/mlb/players/9893'  result = @client.get(url) 

i wasn't able figure out mechanize, able url httparty. if rescue mechanize failure , retry looking redirect uri should set:

require 'mechanize' require 'httparty'  @client = mechanize.new()  url = 'http://sports.yahoo.com/mlb/players/9893'  begin   result = @client.get(url) rescue mechanize::responsecodeerror => e   redirect_url = httparty.get(url).request.last_uri.to_s   result = @client.get(redirect_url) end 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -