如何将我的用户名和密码发布到网页上?

发布于 2024-09-13 18:39:00 字数 1217 浏览 2 评论 0原文

我想用 Perl 将我的用户和密码发布到网站上。登录页面的来源是:

<div class="top">Sign In</div>
    <div class="row"><label for="username">Username:</label></div>
    <div class="row"><div id="login:usernameContainer">
        <input id="login:usernameContainer:username" type="text"
        name="login:usernameContainer:username" class="username" size="16" />
    </div></div>
    <div class="row"><label for="password">Password:</label></div>
    <div class="row"><div id="login:j_id598">
        <input id="login:j_id598:password" type="password"
        name="login:j_id598:password" value="" size="16" class="password" />
    </div></div>
    <div class="clearfix">
    <div class="row rememberme">
        <input id="login:rememberme" type="checkbox"
        name="login:rememberme" class="rememberme" />Remember Me
    </div>
    <div class="submit-button">
        <input type="image" src="/beta/style/shun/base/base/en/text/button/button-login.gif"
        name="login:j_id603" />
    </div>
</div>

我要做什么来发布我的用户和密码?

提前致谢。

I want to post my user and password with Perl to a website. The source of the login page is:

<div class="top">Sign In</div>
    <div class="row"><label for="username">Username:</label></div>
    <div class="row"><div id="login:usernameContainer">
        <input id="login:usernameContainer:username" type="text"
        name="login:usernameContainer:username" class="username" size="16" />
    </div></div>
    <div class="row"><label for="password">Password:</label></div>
    <div class="row"><div id="login:j_id598">
        <input id="login:j_id598:password" type="password"
        name="login:j_id598:password" value="" size="16" class="password" />
    </div></div>
    <div class="clearfix">
    <div class="row rememberme">
        <input id="login:rememberme" type="checkbox"
        name="login:rememberme" class="rememberme" />Remember Me
    </div>
    <div class="submit-button">
        <input type="image" src="/beta/style/shun/base/base/en/text/button/button-login.gif"
        name="login:j_id603" />
    </div>
</div>

What am I going to do to post my user and password?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-09-20 18:39:00

您使用适当的字段名称(您可以在您发布的 HTML 中找到它们)并为您用来发布到页面的任何 Perl 代码填充表单值(WWW::Mechanize 或您使用的任何其他内容)

You use appropriate field names (you can find them in the HTML you posted) and populate the form values for whatever Perl code you use to post to the page (WWW::Mechanize or whatever else you use)

南渊 2024-09-20 18:39:00

请参阅http://search.cpan.org/dist/WWW -Mechanize/lib/WWW/Mechanize.pm 有关该模块的详细信息,但这里有一个尝试:

use strict; use warnings;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get( 'http://url.to/your/form' );
$mech->submit_form(
    form_number => 0,     # see if it's the first form, or change this
    fields      => {
        'login:usernameContainer:username'
            => 'username', # change to your user name
        'login:j_id598:password'
            => 'password', # change to your password
    }
);

如果它不适合您,或者字段始终具有不同的名称等,请尝试使用 $mech->find_link 使用正则表达式并使用返回的值更改您需要的字段,然后提交表单。

希望这有帮助

See http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm for details on the module, but here's a stab at it:

use strict; use warnings;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
$mech->get( 'http://url.to/your/form' );
$mech->submit_form(
    form_number => 0,     # see if it's the first form, or change this
    fields      => {
        'login:usernameContainer:username'
            => 'username', # change to your user name
        'login:j_id598:password'
            => 'password', # change to your password
    }
);

If it doesn't work for you, or the fields have always different names or such, try using $mech->find_link with a regex and use the returned values to change the fields you need, then submit the form.

hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文