【问题标题】:How to use the cookie got from Javascript's document.cookie in Ruby mechanize?如何在 Ruby mechanize 中使用从 Javascript document.cookie 获取的 cookie?
【发布时间】:2016-04-19 22:05:11
【问题描述】:

我正在使用 Ruby 机械化自动化登录过程。因为在 mechanize 中重新创建确切的过程太复杂了,所以我选择使用从浏览器 document.cookie 获取的现有 cookie。我想知道如何在 Ruby mechanize 中使用这个字符串。谢谢。

【问题讨论】:

    标签: javascript ruby cookies mechanize


    【解决方案1】:

    我不认为 Mechanize 运行 Javascript,你必须使用像 Selenium 这样的东西。

    使用 Selenium,您可以运行任意脚本。例如:

    driver = Selenium::WebDriver.for :firefox
    driver.get("http://some.url")
    driver.execute_script("console.log('javascript')")
    driver.close
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多