我有一個HTML,這是我工作的爲什麼我無法在Perl中使用WWW :: Mechanize :: Firefox提交表單?
<form action="/goform/FormUpdateVAP" autocomplete="off" name="myform" id="formid" method="POST">
<table>
<tbody>
<tr>
<td align="right"><span class="label">Name:</span></td>
<td><input id="essid" name="essid" value="X" type="text"></td>
</tr>
<tr>
<td align="right"><input id="broadcast_essid" name="broadcast_essid" value="any" checked="" type="checkbox"></td>
<td><span class="label">Broadcast name:</span></td>
</tr>
</tbody>
</table>
<!-- BEGIN RIGHT COLUMN -->
<table>
<tbody><tr>
<td>
<input name="authentication" id="authentication" value="any" onclick="Update();" type="checkbox"><span class="label"><b>authentication</b></span>
</td>
<td>
<input onclick="Update();" name="wp" id="wp" value="any" type="checkbox"><span class="label"><b>Wp</b></span>
<select id="8021x_mode" name="8021x_mode" onchange="Update();"><option value="wpa">WPA</option>
<option value="wep">WEP</option>
</select>
</td>
</tr>
<tr>
<td height="26">
<input onclick="Update();" name="w_p" id="w_p" value="any" type="checkbox"><span class="label"><b>Wp</b></span>
<select id="8021x_mode" name="8021x_mode" onchange="Update();"><option value="wpa">WPA</option>
<option value="wep">WEP</option>
</select>
</td>
</tr>
<tr>
<td>
<input id="cancel" name="cancel" value="Cancel" onclick="window.location.href = '/fg/list.asp';" type="button">
</td>
<td>
<input id="add-2" name="add" value="Save" type="submit">
</td>
</tr>
</tbody>
</table>
我試圖提交填寫姓名和廣播名稱形式的一部分。並檢查8021x_mode和wp複選框。如果我勾選8021x_mode並設置表單提交的字段就好了。但是,當我嘗試打勾wp它不提交。我沒有收到任何錯誤消息。 這裏是我到目前爲止的代碼:
use WWW::Mechanize::Firefox;
use Crypt::SSLeay;
use URI::Fetch;
use HTML::TagParser;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; #not verifying certificate
my $url = 'https://';
$url = [email protected][0];
my $mech = WWW::Mechanize::Firefox->new;
$mech->get($url);
$mech->form_id('formid');
$mech->tick('8021x_mode','any');
$mech->tick('wp','any'); --after I add this the form doesn't submit
my $name = @ARGV[1];
$mech->set_fields(
'vap_name' => $name,
'essid' => $name,
);
$mech->click_button(id => 'add-2');
$mech->reload();
附加2是提交按鈕。任何想法爲什麼不工作?如果您需要更多信息,請立即告訴我。任何幫助將不勝感激。
第一:**總是**把'use strict;使用警告;'。做到這一點,告訴我們你是否有警告。 –
嗯,我只是這樣做,它給了我**標量值@ARGV [0]更好地寫爲$ ARGV [0] **,併爲我使用的每個參數。它也給了我錯誤**全局符號「$ base_href」需要顯式包名**(我正在傾倒頁面)。所以刪除它,但我想知道這是爲什麼,以及如何解決它。 –
這些警告有助於您識別您的問題。就像它說的那樣,改變'@ARGV [0]到$ ARGV [0]「。至於在'$ base_href'上拋出警告的代碼,這個代碼必須是其他代碼,因爲在這段代碼中我沒有看到'$ base_href'。 –