English 中文(简体)
如何用人工方式为机械化国家添加ok子?
原标题:How to manually add a cookie to Mechanize state?

我在鲁拜工作,但我的问题也适用于其他语文。

我有一个机械化应用。 服务器Im 谈论用 Java(而不是标准板块ook)安装 co子,因此机械化无法捕获 co。 我需要把这一 co子回来,再接下去。

好消息是,我已经知道厨师的价值,但我不知道如何告诉我们,如何把它纳入我的下一个全球教育要求。

最佳回答

这些答案是老的,因此,现在更像现在这样:

cookie = Mechanize::Cookie.new :domain =>  .mydomain.com , :name => name, :value => value, :path =>  / , :expires => (Date.today + 1).to_s
agent.cookie_jar << cookie
问题回答

我以推断(和阅读来源)表示:

agent = Mechanize.new
...
cookie = Mechanize::Cookie.new(key, value)
cookie.domain = ".oddity.com"
cookie.path = "/"
agent.cookie_jar.add(cookie)
...
page = agent.get("https://www.oddity.com/etc")

从事这项工作的人只是罚款。

update

正如@Benjamin Manns所指出的,机械化现在希望在add/code>方法中使用URL。 这里是经过修改的“回报”,假设你利用该代理人从事了全球升温潜能值的工作,所访问的最后一页是厨师的领域(有URI.parse(<>):

agent = Mechanize.new
...
cookie = Mechanize::Cookie.new(key, value)
cookie.domain = ".oddity.com"
cookie.path = "/"
agent.cookie_jar.add(agent.history.last.uri, cookie)
response.to_hash.fetch("set-cookie").each do |c|
  agent.cookie_jar.parse c
end

这里是本土的Ruby,如Net:HTTPOK。





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签