<bdo id='PHRd0'></bdo><ul id='PHRd0'></ul>
<tfoot id='PHRd0'></tfoot>
<i id='PHRd0'><tr id='PHRd0'><dt id='PHRd0'><q id='PHRd0'><span id='PHRd0'><b id='PHRd0'><form id='PHRd0'><ins id='PHRd0'></ins><ul id='PHRd0'></ul><sub id='PHRd0'></sub></form><legend id='PHRd0'></legend><bdo id='PHRd0'><pre id='PHRd0'><center id='PHRd0'></center></pre></bdo></b><th id='PHRd0'></th></span></q></dt></tr></i><div id='PHRd0'><tfoot id='PHRd0'></tfoot><dl id='PHRd0'><fieldset id='PHRd0'></fieldset></dl></div>

<small id='PHRd0'></small><noframes id='PHRd0'>

<legend id='PHRd0'><style id='PHRd0'><dir id='PHRd0'><q id='PHRd0'></q></dir></style></legend>

      1. 用于自动登录和表单提交的 PHP 脚本

        时间:2023-10-02

        <small id='NiN0B'></small><noframes id='NiN0B'>

      2. <tfoot id='NiN0B'></tfoot>

            • <bdo id='NiN0B'></bdo><ul id='NiN0B'></ul>

                  <tbody id='NiN0B'></tbody>

                <legend id='NiN0B'><style id='NiN0B'><dir id='NiN0B'><q id='NiN0B'></q></dir></style></legend>
                • <i id='NiN0B'><tr id='NiN0B'><dt id='NiN0B'><q id='NiN0B'><span id='NiN0B'><b id='NiN0B'><form id='NiN0B'><ins id='NiN0B'></ins><ul id='NiN0B'></ul><sub id='NiN0B'></sub></form><legend id='NiN0B'></legend><bdo id='NiN0B'><pre id='NiN0B'><center id='NiN0B'></center></pre></bdo></b><th id='NiN0B'></th></span></q></dt></tr></i><div id='NiN0B'><tfoot id='NiN0B'></tfoot><dl id='NiN0B'><fieldset id='NiN0B'></fieldset></dl></div>
                • 本文介绍了用于自动登录和表单提交的 PHP 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个外部网站,需要我一个.登录湾post表单(带有2-3个动态参数)

                  I have an external site which requires me to a. login b. post form (with 2-3 dyanamic parameters)

                  我需要一个 PHP 脚本来自动执行此行为.即脚本应首先使用用户名/密码登录,然后导航到 URL 并提交表单(使用动态参数)

                  I need a PHP script to automate this behavior. i.e. the script should first login with a username/password and then navigate to the URL and submit the form (using dyanamic parameters)

                  如何使用 PHP 执行相同的操作?

                  How can I do the same using PHP?

                  推荐答案

                  我推荐使用这个类:

                  http://semlabs.co.uk/日志/面向对象的curl-class-with-multi-threading

                  它会是这样的:

                  $c = new CURLRequest();
                  $c->retry = 2;
                  $c->get( $url, $this->curlOpts );
                  $url = 'https://secure.login.co.uk/';
                  $opts = array(
                      CURLOPT_USERAGENT       => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
                      CURLOPT_COOKIEFILE      => 'anc.tmp',
                      CURLOPT_COOKIEJAR       => 'anc.tmp',
                      CURLOPT_FOLLOWLOCATION  => 1,
                      CURLOPT_RETURNTRANSFER  => 1,
                      CURLOPT_SSL_VERIFYHOST  => 0,
                      CURLOPT_SSL_VERIFYPEER  => 0,
                      CURLOPT_TIMEOUT         => 120
                  );
                  $opts[CURLOPT_POSTFIELDS] = 'username=user&password=pass&submit=1';
                  $request = $c->get( $url, $opts );
                  

                  注意有些网站要求您先下载登录页面以设置 cookie.

                  N.B. Some sites require you to download the login page first to set a cookie.

                  此外,您需要对帖子字段中的特殊字符进行 url_encode.

                  Also, you need to url_encode special chars in the post fields.

                  这篇关于用于自动登录和表单提交的 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:自动检测文件中是否存在 CSV 标头 下一篇:有没有办法在 php 中的沙箱中执行 php 代码

                  相关文章

                  最新文章

                  • <bdo id='eKVSL'></bdo><ul id='eKVSL'></ul>
                • <i id='eKVSL'><tr id='eKVSL'><dt id='eKVSL'><q id='eKVSL'><span id='eKVSL'><b id='eKVSL'><form id='eKVSL'><ins id='eKVSL'></ins><ul id='eKVSL'></ul><sub id='eKVSL'></sub></form><legend id='eKVSL'></legend><bdo id='eKVSL'><pre id='eKVSL'><center id='eKVSL'></center></pre></bdo></b><th id='eKVSL'></th></span></q></dt></tr></i><div id='eKVSL'><tfoot id='eKVSL'></tfoot><dl id='eKVSL'><fieldset id='eKVSL'></fieldset></dl></div>
                • <small id='eKVSL'></small><noframes id='eKVSL'>

                  <legend id='eKVSL'><style id='eKVSL'><dir id='eKVSL'><q id='eKVSL'></q></dir></style></legend>

                • <tfoot id='eKVSL'></tfoot>