Fedex Ruby Mechanize:无法登录

时间:2017-04-08 21:04:33

标签: ruby login mechanize fedex

我正在尝试通过Ruby gem Mechanize自动化我的fedex处理。 我已经设置了类似于在Amazon Seller Central页面上为我工作的初始脚本。但是,我似乎无法完全登录到fedex网站,而我似乎只是“停留”在登录页面上。

如果你知道我的代码丢失了什么,我们将不胜感激!

CODE

Dir.chdir 'C:\Ruby22\bin'
require "rubygems"
require "mechanize"
require "certified"
require "logger"

#Initialize and set agent settings:
agent = Mechanize.new
agent.user_agent_alias = 'Windows Chrome'
agent.follow_meta_refresh = true
agent.redirect_ok = true

#Log in to fedex
login_url = "https://www.fedex.com/dk/"
page_login = agent.get(login_url)
puts "Login Page: " + page_login.title.to_s

form = page_login.form_with(:name => "logonForm")
#form.fields.each { |f| puts f.name }
form.username = "************"
form['ap_signin_existing_radio'] = "1"
form.password = "*********"
agent.submit(form)
page_home = agent.get(login_url)
puts "Fedex Dashboard Page: " + page_home.title

0 个答案:

没有答案