繁体   English   中英

如何在Ruby Mechanize中使用从Javascript的document.cookie获得的cookie?

[英]How to use the cookie got from Javascript's document.cookie in Ruby mechanize?

我使用Ruby机械化使登录过程自动化。 由于过于复杂以致无法在机械化中重新创建确切的过程,因此我选择使用从浏览器document.cookie抓取的现有cookie。 我想知道如何在Ruby机械化中使用此字符串。 谢谢。

我不认为Mechanize运行Javascript,您必须使用Selenium之类的工具。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM