尝试使用ruby机械化发布 [英] trying to POST with ruby mechanize
本文介绍了尝试使用ruby机械化发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用firefox插件LiveHTTPheaders捕获了登录HTTP标头.
I've captured the login HTTP headers using firefox plugin LiveHTTPheaders.
我找到了以下网址和变量.
I've found the following url and variables.
POST /login
email=myemail%40gmail.com&password=something&remember=1&loginSubmit=Login
这是我正在运行的代码:
And here's the code I am running:
require 'rubygems'
require 'mechanize'
browser = Mechanize.new
browser.post('http://www.mysite.com/login',
[
["email","myemail%40gmail.com"],
["password","something"],
["remember","1"],
["loginSubmit","Login"],
["url"=>""]
]
) do |page|
puts page.body
end
但是,这什么也给不了我!我的post参数有问题吗?
However, this gives me nothing ! is something wrong with my post parameters ?
推荐答案
post()不会阻塞.试试这个:
post() doesn't take a block. Try this:
page = browser.post('http://www.mysite.com/login', {
"email" => "myemail%40gmail.com",
"password" => "something",
"remember" => "1",
"loginSubmit" => "Login",
"url" => ""
})
为了准确性而更改
这篇关于尝试使用ruby机械化发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文