1

mechanize を使用して oracle アカウントにログインし、次のホーム サイトを表示する Ruby ツールを作成しようとしています。

#!/usr/bin/ruby
require 'rubygems'
require 'open-uri'
require 'mechanize' 
require 'nokogiri'

agent = Mechanize.new
login_form = agent.get("https://login.oracle.com/mysso/signon.jsp").form("LoginForm")
login_form.request_id = 'username'
login_form.locale = 'password'

page = agent.submit(login_form, login_form.buttons.first)
page.body.match /content="1;URL=(.*?)"/
nexturl = $1
newpage = agent.get nexturl
puts newpage.body

現時点では、次のページを読み込むことができますが、ログインに失敗したというメッセージしか表示されません (「システム エラーです。アクションを再試行してください。」)。ログインサイトがhttps://サイトなのが問題なのかな?

問題は、Mechanize が必要なログイン フィールドを取得できないことにあることがわかりました。

<form method="post" action="/oam/server/sso/auth_cred_submit" name="LoginForm"         autocomplete="off">
<input type="hidden" name="v" value="v1.4">
<input type="hidden" name="request_id" value="">
<input type="hidden" name="locale" value="">
<span id="errormsg" class="error-show">
Error! Do not use bookmarked URL.<br>Please type the URL you are trying to reach directly into your browser.
</span>
</form>

サイトをカールすると、これらのエラーが発生し、必要なフィールドが受信フォームに含まれていません。ログインに必要なフィールドは、エラー メッセージが表示されている場所から始まります...

ご協力いただきありがとうございます

4

0 に答える 0