私は Mechanize を使用して、サポート ポータルにログインし、私の職場のサポート トラブル チケットを送信するプロセスを自動化しようとしている Ruby 初心者です (そのため、定期的/一貫した要求を送信することを覚えておく必要はありません。サポート ポータルは、サポート リクエストを送信するための Web フォームを備えた ASP ベースの Web サイトです。サイトにログインする Ruby スクリプトを作成できましたが、サポート リクエストを送信しようとすると行き詰まります。スクリプトが実行され、正常にログインして送信するように見えますが、実際にはウェブサイトに何も送信されません.STDOUTにエラーは表示されません.スクリプトコードとmechanizeからのログの一部を含めています.誰かが何かヒントを持っているなら、私はとても感謝しています:) 繰り返しになりますが、私は Ruby と Mechanize に慣れていないので、おそらく明らかな何かが欠けています。
-クリス
機械化 Ruby スクリプトは次のとおりです。
require 'rubygems'
require 'mechanize'
require 'logger'
agent = Mechanize.new { |agent|
agent.open_timeout = 5
agent.read_timeout = 5
}
agent.user_agent_alias = 'Mac Safari'
agent.log = Logger.new("mech.log")
page = agent.get ('https://www.mysite.org/default.aspx')
# Login to web portal
form = page.form_with(:action => 'default.aspx')
form.field_with(:name => "ctl00$SiteContent$tbAccessId").value = ARGV[0]
form.field_with(:name => "ctl00$SiteContent$tbPassword").value = ARGV[1]
page = form.click_button
# Access the support request form after logging in
page = agent.get ('https://www.mysite.org/helpdesk/default2.aspx')
form = page.form_with(:name => 'aspnetForm')
form['__EVENTARGUMENT'] = ''
form['__EVENTTARGET'] = 'ctl00$SiteContent$btnSubmit'
form["ctl00$SiteContent$ddlType"] = "10"
form["ctl00$SiteContent$ddlCategory"] = "2"
form["ctl00$SiteContent$rbtnUrgency"] = "Standard"
form["ctl00$SiteContent$txtDescription"] = "This is a test."
page = form.click_button
スクリプトを実行した後、mech.log に次のように表示されます。
AuCB8egKAuOB%2FegKAuGBresKAsOr%2B54KArvqu9YLArvqu9YLArWF4bsHArWFkbgHArSFsbgHArSF4bsHAreF0bsHAreF2bsHAreF3bsHArSF5bsHAraFvbgHArWFsbgHArWFvbgHAraFsbgHAreF7bsHArWF3bsHAreF6bsHAreF4bsHAreF9bsHAuTcrvoPAu2zhJQDAuuzhJQDAumzhJQDAuizhJQDAvyzhJQDAuuzxJcDAu6zhJQDAu%2BzhJQDAvOzhJQDAuqzhJQDAouM7vYPArKV8PkDAomzw8AJAqq7yucNAqbmgdMOAuLPiYYOAtv24HwCrbHt7goC9KHh9gkCrtjkwQsCwOeDqgQCocHXsAoCqKfM2wTlhszuh%2F2iy3Lw4%2FAOkPihaler%2Fg%3D%3D&.x=0&.y=0&ctl00%24SiteContent%24QuickSearch1%24SearchString=&ctl00%24SiteContent%24QuickSearch1%24SearchType=&ctl00%24SiteContent%24ctl00%24txtRequester=+&ctl00%24SiteContent%24ctl00%24Type=&ctl00%24SiteContent%24ctl00%24Group=&ctl00%24SiteContent%24ctl00%24Status=1&ctl00%24SiteContent%24ctl00%24Location=&ctl00%24SiteContent%24ctl00%24urgency=Standard&ctl00%24SiteContent%24ctl00%24RequestDescription=&ctl00%24SiteContent%24ctl00%24Resolution=&ctl00%24SiteContent%24ctl00%24RelatedTo=&ctl00%24SiteContent%24ctl00%24rid=0&ctl00%24SiteContent%24ddlType=10&ctl00%24SiteContent%24ddlCategory=2&ctl00%24SiteContent%24rbtnUrgency=Standard&ctl00%24SiteContent%24txtDescription=This+is+a+test."
I, [2013-09-05T16:14:30.311457 #6252] INFO -- : Net::HTTP::Post: /amm/default.aspx?cmd=servicerequest
D, [2013-09-05T16:14:30.311604 #6252] DEBUG -- : request-header: accept => */*
D, [2013-09-05T16:14:30.311654 #6252] DEBUG -- : request-header: user-agent => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22
D, [2013-09-05T16:14:30.311700 #6252] DEBUG -- : request-header: accept-encoding => gzip,deflate,identity
D, [2013-09-05T16:14:30.311746 #6252] DEBUG -- : request-header: accept-charset => ISO-8859-1,utf-8;q=0.7,*;q=0.7
D, [2013-09-05T16:14:30.311790 #6252] DEBUG -- : request-header: accept-language => en-us,en;q=0.5
D, [2013-09-05T16:14:30.311836 #6252] DEBUG -- : request-header: cookie => ASP.NET_SessionId=l2kdmf45qsxi4wvyzgiud0zr; WebPortal="UserID=2869&lastVisit=9/5/2013 4:16:33 PM"; CallTracWeb=testuser
D, [2013-09-05T16:14:30.311881 #6252] DEBUG -- : request-header: host => www.mysite.org
D, [2013-09-05T16:14:30.311935 #6252] DEBUG -- : request-header: referer => https://www.mysite.org/amm/default.aspx?cmd=servicerequest
D, [2013-09-05T16:14:30.311981 #6252] DEBUG -- : request-header: content-type => application/x-www-form-urlencoded
D, [2013-09-05T16:14:30.312027 #6252] DEBUG -- : request-header: content-length => 1525791
I, [2013-09-05T16:14:33.014920 #6252] INFO -- : status: Net::HTTPOK 1.1 200 OK
D, [2013-09-05T16:14:33.015064 #6252] DEBUG -- : response-header: cache-control => private
D, [2013-09-05T16:14:33.015115 #6252] DEBUG -- : response-header: content-length => 1551484
D, [2013-09-05T16:14:33.015163 #6252] DEBUG -- : response-header: content-type => text/html; charset=utf-8
D, [2013-09-05T16:14:33.015208 #6252] DEBUG -- : response-header: etag => ""
D, [2013-09-05T16:14:33.015253 #6252] DEBUG -- : response-header: server => Microsoft-IIS/6.0
D, [2013-09-05T16:14:33.015299 #6252] DEBUG -- : response-header: x-powered-by => ASP.NET
D, [2013-09-05T16:14:33.015345 #6252] DEBUG -- : response-header: x-aspnet-version => 2.0.50727
D, [2013-09-05T16:14:33.015389 #6252] DEBUG -- : response-header: date => Thu, 05 Sep 2013 23:16:39 GMT
D, [2013-09-05T16:14:33.015901 #6252] DEBUG -- : Read 16150 bytes (16150 total)
D, [2013-09-05T16:14:33.016371 #6252] DEBUG -- : Read 16360 bytes (32510 total)
D, [2013-09-05T16:14:33.016654 #6252] DEBUG -- : Read 16384 bytes (48894 total)
D, [2013-09-05T16:14:33.016945 #6252] DEBUG -- : Read 16360 bytes (65254 total)
D, [2013-09-05T16:14:33.018320 #6252] DEBUG -- : Read 16384 bytes (81638 total)
D, [2013-09-05T16:14:33.025665 #6252] DEBUG -- : Read 16360 bytes (97998 total)
D, [2013-09-05T16:14:33.026133 #6252] DEBUG -- : Read 16384 bytes (114382 total)
D, [2013-09-05T16:14:33.026408 #6252] DEBUG -- : Read 16360 bytes (130742 total)
D, [2013-09-05T16:14:33.026682 #6252] DEBUG -- : Read 16384 bytes (147126 total)
D, [2013-09-05T16:14:33.027781 #6252] DEBUG -- : Read 16360 bytes (163486 total)
D, [2013-09-05T16:14:33.029723 #6252] DEBUG -- : Read 16384 bytes (179870 total)
D, [2013-09-05T16:14:33.031066 #6252] DEBUG -- : Read 16360 bytes (196230 total)
D, [2013-09-05T16:14:33.032051 #6252] DEBUG -- : Read 16384 bytes (212614 total)
D, [2013-09-05T16:14:33.032862 #6252] DEBUG -- : Read 16360 bytes (228974 total)
D, [2013-09-05T16:14:33.033299 #6252] DEBUG -- : Read 16384 bytes (245358 total)
D, [2013-09-05T16:14:33.034354 #6252] DEBUG -- : Read 16360 bytes (261718 total)
D, [2013-09-05T16:14:33.035249 #6252] DEBUG -- : Read 16384 bytes (278102 total)
D, [2013-09-05T16:14:33.036609 #6252] DEBUG -- : Read 16360 bytes (294462 total)
D, [2013-09-05T16:14:33.037490 #6252] DEBUG -- : Read 16384 bytes (310846 total)
D, [2013-09-05T16:14:33.038701 #6252] DEBUG -- : Read 16360 bytes (327206 total)
D, [2013-09-05T16:14:33.040118 #6252] DEBUG -- : Read 16384 bytes (343590 total)
D, [2013-09-05T16:14:33.041504 #6252] DEBUG -- : Read 16360 bytes (359950 total)
D, [2013-09-05T16:14:33.042945 #6252] DEBUG -- : Read 16384 bytes (376334 total)
D, [2013-09-05T16:14:33.044316 #6252] DEBUG -- : Read 16360 bytes (392694 total)
D, [2013-09-05T16:14:33.045664 #6252] DEBUG -- : Read 16384 bytes (409078 total)
D, [2013-09-05T16:14:33.046981 #6252] DEBUG -- : Read 16360 bytes (425438 total)
D, [2013-09-05T16:14:33.048278 #6252] DEBUG -- : Read 16384 bytes (441822 total)
D, [2013-09-05T16:14:33.049844 #6252] DEBUG -- : Read 16360 bytes (458182 total)
D, [2013-09-05T16:14:33.051117 #6252] DEBUG -- : Read 16384 bytes (474566 total)
D, [2013-09-05T16:14:33.052430 #6252] DEBUG -- : Read 16360 bytes (490926 total)
D, [2013-09-05T16:14:33.054650 #6252] DEBUG -- : Read 16384 bytes (507310 total)
D, [2013-09-05T16:14:33.056121 #6252] DEBUG -- : Read 16360 bytes (523670 total)
D, [2013-09-05T16:14:33.056731 #6252] DEBUG -- : Read 16384 bytes (540054 total)
D, [2013-09-05T16:14:33.058726 #6252] DEBUG -- : Read 16360 bytes (556414 total)
D, [2013-09-05T16:14:33.059730 #6252] DEBUG -- : Read 16384 bytes (572798 total)
D, [2013-09-05T16:14:33.061074 #6252] DEBUG -- : Read 16360 bytes (589158 total)
D, [2013-09-05T16:14:33.062792 #6252] DEBUG -- : Read 16384 bytes (605542 total)
D, [2013-09-05T16:14:33.065304 #6252] DEBUG -- : Read 16360 bytes (621902 total)
D, [2013-09-05T16:14:33.066338 #6252] DEBUG -- : Read 16384 bytes (638286 total)
D, [2013-09-05T16:14:33.066970 #6252] DEBUG -- : Read 16360 bytes (654646 total)
D, [2013-09-05T16:14:33.067861 #6252] DEBUG -- : Read 16384 bytes (671030 total)
D, [2013-09-05T16:14:33.069398 #6252] DEBUG -- : Read 16360 bytes (687390 total)
D, [2013-09-05T16:14:33.071889 #6252] DEBUG -- : Read 16384 bytes (703774 total)
D, [2013-09-05T16:14:33.072849 #6252] DEBUG -- : Read 16360 bytes (720134 total)
D, [2013-09-05T16:14:33.073747 #6252] DEBUG -- : Read 16384 bytes (736518 total)
D, [2013-09-05T16:14:33.075222 #6252] DEBUG -- : Read 16360 bytes (752878 total)
D, [2013-09-05T16:14:33.076821 #6252] DEBUG -- : Read 16384 bytes (769262 total)
D, [2013-09-05T16:14:33.077482 #6252] DEBUG -- : Read 16360 bytes (785622 total)
D, [2013-09-05T16:14:33.079212 #6252] DEBUG -- : Read 16384 bytes (802006 total)
D, [2013-09-05T16:14:33.080905 #6252] DEBUG -- : Read 16360 bytes (818366 total)
D, [2013-09-05T16:14:33.081823 #6252] DEBUG -- : Read 16384 bytes (834750 total)
D, [2013-09-05T16:14:33.082952 #6252] DEBUG -- : Read 16360 bytes (851110 total)
D, [2013-09-05T16:14:33.084447 #6252] DEBUG -- : Read 16384 bytes (867494 total)
D, [2013-09-05T16:14:33.087447 #6252] DEBUG -- : Read 16360 bytes (883854 total)
D, [2013-09-05T16:14:33.088806 #6252] DEBUG -- : Read 16384 bytes (900238 total)
D, [2013-09-05T16:14:33.089667 #6252] DEBUG -- : Read 16360 bytes (916598 total)
D, [2013-09-05T16:14:33.090558 #6252] DEBUG -- : Read 16384 bytes (932982 total)
D, [2013-09-05T16:14:33.092264 #6252] DEBUG -- : Read 16360 bytes (949342 total)
D, [2013-09-05T16:14:33.093337 #6252] DEBUG -- : Read 16384 bytes (965726 total)
D, [2013-09-05T16:14:33.094364 #6252] DEBUG -- : Read 16360 bytes (982086 total)
D, [2013-09-05T16:14:33.095606 #6252] DEBUG -- : Read 16384 bytes (998470 total)
D, [2013-09-05T16:14:33.097239 #6252] DEBUG -- : Read 16360 bytes (1014830 total)
D, [2013-09-05T16:14:33.098906 #6252] DEBUG -- : Read 16384 bytes (1031214 total)
D, [2013-09-05T16:14:33.099863 #6252] DEBUG -- : Read 16360 bytes (1047574 total)
D, [2013-09-05T16:14:33.101937 #6252] DEBUG -- : Read 16384 bytes (1063958 total)
D, [2013-09-05T16:14:33.103009 #6252] DEBUG -- : Read 16360 bytes (1080318 total)
D, [2013-09-05T16:14:33.105271 #6252] DEBUG -- : Read 16384 bytes (1096702 total)
D, [2013-09-05T16:14:33.106769 #6252] DEBUG -- : Read 16360 bytes (1113062 total)
D, [2013-09-05T16:14:33.108198 #6252] DEBUG -- : Read 16384 bytes (1129446 total)
D, [2013-09-05T16:14:33.109602 #6252] DEBUG -- : Read 16360 bytes (1145806 total)
D, [2013-09-05T16:14:33.111058 #6252] DEBUG -- : Read 16384 bytes (1162190 total)
D, [2013-09-05T16:14:33.111743 #6252] DEBUG -- : Read 16360 bytes (1178550 total)
D, [2013-09-05T16:14:33.112553 #6252] DEBUG -- : Read 16384 bytes (1194934 total)
D, [2013-09-05T16:14:33.114957 #6252] DEBUG -- : Read 16360 bytes (1211294 total)
D, [2013-09-05T16:14:33.117778 #6252] DEBUG -- : Read 16384 bytes (1227678 total)
D, [2013-09-05T16:14:33.119007 #6252] DEBUG -- : Read 16360 bytes (1244038 total)
D, [2013-09-05T16:14:33.119392 #6252] DEBUG -- : Read 16384 bytes (1260422 total)
D, [2013-09-05T16:14:33.120486 #6252] DEBUG -- : Read 16360 bytes (1276782 total)
D, [2013-09-05T16:14:33.122038 #6252] DEBUG -- : Read 16384 bytes (1293166 total)
D, [2013-09-05T16:14:33.123997 #6252] DEBUG -- : Read 16360 bytes (1309526 total)
D, [2013-09-05T16:14:33.125114 #6252] DEBUG -- : Read 16384 bytes (1325910 total)
D, [2013-09-05T16:14:33.126124 #6252] DEBUG -- : Read 16360 bytes (1342270 total)
D, [2013-09-05T16:14:33.141879 #6252] DEBUG -- : Read 16384 bytes (1358654 total)
D, [2013-09-05T16:14:33.142287 #6252] DEBUG -- : Read 16360 bytes (1375014 total)
D, [2013-09-05T16:14:33.142563 #6252] DEBUG -- : Read 16384 bytes (1391398 total)
D, [2013-09-05T16:14:33.143085 #6252] DEBUG -- : Read 16360 bytes (1407758 total)
D, [2013-09-05T16:14:33.145897 #6252] DEBUG -- : Read 16384 bytes (1424142 total)
D, [2013-09-05T16:14:33.147198 #6252] DEBUG -- : Read 16360 bytes (1440502 total)
D, [2013-09-05T16:14:33.148707 #6252] DEBUG -- : Read 16384 bytes (1456886 total)
D, [2013-09-05T16:14:33.150672 #6252] DEBUG -- : Read 16360 bytes (1473246 total)
D, [2013-09-05T16:14:33.151736 #6252] DEBUG -- : Read 16384 bytes (1489630 total)
D, [2013-09-05T16:14:33.153504 #6252] DEBUG -- : Read 16360 bytes (1505990 total)
D, [2013-09-05T16:14:33.155381 #6252] DEBUG -- : Read 16384 bytes (1522374 total)
D, [2013-09-05T16:14:33.156526 #6252] DEBUG -- : Read 16360 bytes (1538734 total)