您好,我有一个带有 URL-ENCODING 、 %3A 、 %2F 的字符串...
http%3A%2F%2Fmydomain.com%2Fimage%2Fflv%2F1%2F8%2Fa%2Fimage_18060.jpg%3Fe%3D13777194
我想将“特殊字符” http://www.w3schools.com/tags/ref_urlencode.asp替换为 ASCII 字符,我正在 Rails 中编程,但我不知道从哪里开始。你有什么想法?
非常感谢您的帮助!
嗯,这样我可以使用URI.unescape吗?
scraper = Scraper.define do
array :items
process "div.mozaique>div", :items => Scraper.define {
process "div.thumb>a", URI.unescape(:link) => "@href"
result :link
}
result :items
end
/Users/jcr/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/uri/common.rb:331:in `unescape': undefined method `gsub' for :link:Symbol (NoMethodError)
from /Users/jcr/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/uri/common.rb:649:in `unescape'
from /Users/jcr/web/sss/app/controllers/cweb.rb:17:in `block (2 levels) in main_web'
from /Users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/scrapi-2.0.0/lib/scraper/base.rb:986:in `module_eval'
from /Users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/scrapi-2.0.0/lib/scraper/base.rb:986:in `define'
from /Users/jcr/web/sss/app/controllers/cweb.rb:15:in `block in main_web'
from /Users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/scrapi-2.0.0/lib/scraper/base.rb:986:in `module_eval'
from /Users/jcr/.rvm/gems/ruby-1.9.3-p448/gems/scrapi-2.0.0/lib/scraper/base.rb:986:in `define'
from /Users/jcr/web/sss/app/controllers/cweb.rb:13:in `main_web'
from /Users/jcr/web/sss/app/controllers/cweb.rb:57:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'