机械化在从网页读取链接的 href 时将"~"替换为"̅"



我正在使用Mechanize Ruby gem来抓取 epinions.com 的一些内容。但不知何故,某些链接没有得到正确的解释。这是由于机械化将~替换为引起的。结果是机械化无法单击该链接。

不成功,然后成功抓取的示例:

# script
agent = Mechanize.new
page_1 = agent.get("http://www.epinions.com/webs-Web_Services-All-Merchants-AtomicPark_com/display_~reviews")
puts page_1.links_with(:href => /full_specs/, :text => /^View Information$/).last.inspect
page_2 = agent.get("http://www.epinions.com/webs-Web_Services-All-Merchants-Vanns_com/display_~reviews")
puts page_2.links_with(:href => /full_specs/, :text => /^View Information$/).last.inspect
# result
#<Mechanize::Page::Link
 "View Information"
 "/webs-Web_Services-All-Merchants-AtomicPark_com/display_‾full_specs">
#<Mechanize::Page::Link
 "View Information"
 "/webs-Web_Services-All-Merchants-Vanns_com/display_~full_specs">

知道为什么会这样吗?

这对我来说很好用:

[14:29] arkham ~/Desktop [2.1.0]
↳ $ ruby mechanize.rb
#<Mechanize::Page::Link
 "View Information"
 "/webs-Web_Services-All-Merchants-AtomicPark_com/display_~full_specs">
#<Mechanize::Page::Link
 "View Information"
 "/webs-Web_Services-All-Merchants-Vanns_com/display_~full_specs">

您使用的是哪个版本的 Ruby?

最新更新