尝试使用 Mechanize 浏览 KBB.com。我创建一个新代理
agent = Mechanize.new
工作正常。
page = agent.get('http://www.kbb.com/toyota/mr2/1993-toyota-mr2/
styles/?intent=buy-used')
返回页面。
page.link_with(:text => "Choose this style").click
给我这个
page.link_with(:text => "Choose this style").click
Mechanize::ResponseCodeError: 500 => Net::HTTPInternalServerError for
http://www.kbb.com /toyota/mr2/1993-toyota-mr2/coupe-2d/options/?
vehicleid=11263&intent=buy- used&pricetype=&path=&filter= -- unhandled response
在 craigslist 上运行良好。为什么不是kbb?
最佳答案
我能够重现这一点,看起来其中一个 cookie 已损坏。任何其他请求都会失败。
您可以通过在每次请求之前清除 cookie jar 来解决此问题。
agent.cookie_jar.clear!
关于ruby-on-rails - Mechanize 无法导航 KBB.com,获取 Mechanize::ResponseCodeError: 500 => Net::HTTPInternalServerError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20155740/