gpt4 book ai didi

ruby - 尝试形成 POST 查询时 Mechanize Iconv::IllegalSequence

转载 作者:数据小太阳 更新时间:2023-10-29 08:13:56 25 4
gpt4 key购买 nike

以下代码引发了上述错误,我该如何解决?

require 'mechanize'
m = WWW::Mechanize.new
p = m.get('http://art-mobile.com.ua/register.php')
f = p.forms.first
f.submit(f.buttons.last)

以防万一,这里是我盒子上错误的完整描述

D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/util.rb:40:in `iconv': "Ðåãèñòðàöèÿ"... (Iconv::IllegalSequence)
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/util.rb:40:in `from_native_charset'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:152:in `from_native_charset'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:144:in `block in proc_query'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:143:in `map'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:143:in `proc_query'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:198:in `block in build_query'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:197:in `each'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:197:in `build_query'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:214:in `request_data'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize.rb:401:in `post_form'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize.rb:344:in `submit'
from D:/ruby/lib/ruby/gems/1.9.1/gems/mechanize-0.9.3/lib/www/mechanize/form.rb:130:in `submit'
from D:/doer.rb:8:in `<main>'

顺便说一句 this solution不工作

最佳答案

看起来解决方案是稍微重写 gem,以便在初始化新页面时将页面的编码转换为 utf-8,将 @encoding var 更改为 utf-8 并将原始编码存储在另一个文件中,并进行必要的更改以强制 gem 在形成查询时使用原始编码

关于ruby - 尝试形成 POST 查询时 Mechanize Iconv::IllegalSequence,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1323839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com