gpt4 book ai didi

ruby - 使用 click_link 时错误的 URI(不是 URI?)

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

我有一个看起来像这样的代码行:

click_link "link page with spaces"

链接在 HTML 中看起来像这样:

<a href="page with spaces">link page with spaces</a>

当这条线运行时,我得到:

bad URI(is not URI?): page with spaces
/opt/rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/uri/common.rb:176:in `split'

我知道问题是因为链接包含未转换为 %20 的空格,但我不确定如何解决它。

最佳答案

您能否在生成 uri 的任何地方对其进行转义?

require 'uri'
URI.escape("page with spaces") # => "page%20with%20spaces"

关于ruby - 使用 click_link 时错误的 URI(不是 URI?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19214198/

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