[問題] Vertical Bar in URL (網址中有'|')
環境:
Ruby 1.9.2
狀況:
網址中有vertical bar '|'
會被ruby判定為invalid URI
附錄:
require 'net/http'
#url內有'|'符號!瀏覽器可接受此網址,但ruby無法get該網頁內容
url = http://maps.google.com/maps/api/directions/json?sensor=false&origin=New+York+City,+USA&destination=Washington+DC,+USA&waypoints=optimize:true|Philadelphia,+PA|Newark,+NJ
Net::HTTP.get(::URI.parse(url))
錯誤訊息:
D:/Ruby192/lib/ruby/1.9.1/uri/common.rb:156:in `split': bad URI(is not URI?): ht
tp://maps.google.com/maps/api/directions/json?sensor=false&origin=New+York+City,
+USA&destination=Washington+DC,+USA&waypoints=optimize:true|Philadelphia,+PA|New
ark,+NJ (URI::InvalidURIError)
from D:/Ruby192/lib/ruby/1.9.1/uri/common.rb:174:in `parse'
from D:/Ruby192/lib/ruby/1.9.1/uri/common.rb:628:in `parse'
from xmlReader.rb:70:in `get_url'
from xmlReader.rb:55:in `xml'
from xmlReader.rb:47:in `find_status'
from xmlReader.rb:43:in `initialize'
from xmlReader.rb:83:in `new'
from xmlReader.rb:83:in `<main>'
shell returned 1
請問該如何解決?
感謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 96.32.170.168
→
11/06 13:53, , 1F
11/06 13:53, 1F
→
11/06 14:25, , 2F
11/06 14:25, 2F
→
11/06 16:43, , 3F
11/06 16:43, 3F
Ruby 近期熱門文章
PTT數位生活區 即時熱門文章