【问题标题】:Access current URI of Nokogiri HTML Document访问 Nokogiri HTML 文档的当前 URI
【发布时间】:2013-09-16 13:39:34
【问题描述】:

我需要访问我当前所在页面的 url(保存为 Nokogiri HTML 文档)以从中获取某些参数。这是我尝试过的:

agent = Mechanize.new
page = agent.get('some.url.com/?parameter1=234').parser
page.uri.match(/\/\?parameter1=(\d*)/)[1].to_s

如您所见,我想提取 parameter1 的值。

任何关于如何去做的想法将不胜感激!

注意! 这不是删除 .parser 方法的选项,因为我需要在脚本中更进一步。

【问题讨论】:

    标签: ruby url nokogiri mechanize


    【解决方案1】:

    试试agent.history.last.uri.to_s

    【讨论】:

      猜你喜欢
      • 2011-11-23
      • 1970-01-01
      • 2018-01-18
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多