我得到了一个简单的登录脚本,它可以正常工作,直到它尝试使用 åäö 等字母。我没有收到错误,但登录只是失败了,所以我认为编码搞砸了。我该如何解决这个问题?提前致谢!
# encoding: utf-8
require 'nokogiri'
require 'mechanize'
agent = Mechanize.new
page = agent.get("site.com/login.php")
form = page.forms.last
form.namn = 'Johan.Björk'
form.losen = 'password'
button = form.button_with(:value => "Login")
site = agent.submit(form, button)
if site.body.include? "Wrong User/Password"
puts 'fail'
else
puts 'success'
end