PHP抓取-通过curl提交Javascript“ onclick”表单

时间:2019-05-20 12:34:23

标签: php forms curl

我会通过Curl + PHP在远程服务器上调用javascript函数。提交按钮是一个div元素,并通过“ onclick”调用函数。

刮板步骤:
1.登录
2.保存会话
3.使用会话

调用安全链接

问题:如何通过curl提交Javascript“ onclick”表单?

我将采用以下形式实现PHP-Scraper:

<script language="JavaScript" type="text/javascript">
            function logon() {
                if(document.forms['form1'].elements["USERNAME"].value==""){
                    alert('foo');
                    document.forms['form1'].elements["USERNAME"].focus();
                    return paxReturn(false);
                }
                if(document.forms['form1'].elements["PASSWORD"].value==""){
                    alert('foo');
                    document.forms['form1'].elements["PASSWORD"].focus();
                    return paxReturn(false);
                }


                    if (mywindow!=null) {
                        showObjectWithSrvlt('paxInfo','LoginServlet');
                    }
                    if((mywindow==null)||(mywindow.closed)) {
                        var prm ='toolbar=no,titlebar=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,width=900,height=600,top=0,left=0';
                        mywindow = window.open("",'bar',prm);   
                     }
                     document.forms['form1'].target = 'bar';
                     try{
                          mywindow.resizeTo(screen.width,screen.height);
                     }catch(e) {}

                document.forms['form1'].submit(); 

               try{
                  mywindow.focus();
               }catch(e) {}
               document.forms['form1'].elements["USERNAME"].value="";
               document.forms['form1'].elements["PASSWORD"].value="";
               /* grecaptcha.reset(); */
            }
        </script>
<form name="form1" method="post" target="foo" action="foo.jsp"> 
        <input class="FormText" type="hidden" name="clickedButton" id="clickedButton" value="">
        <input class="FormText" type="hidden" name="paxInfo" id="paxInfo" value="">
        <div class="col-lg-10 col-md-12">
           <div class="card mask">

            <br>
            <br>
            <table class="login-table-list">

                <tbody><tr>
                    <td><div align="right">Username:&nbsp;&nbsp;</div></td>
                    <td><input type="text" name="USERNAME" value="" maxlength=" 20" size=" 18" class="InputText " id="USERNAME" autocomplete="OFF"></td>
                </tr>
                <tr><td colspan="2">&nbsp;</td></tr>
                <tr>
                    <td><div align="right">Password:&nbsp;&nbsp;</div></td>
                    <td><b><input class="InputText" type="password" name="PASSWORD" size="18" value="" onkeypress="javascript:return login(event);" autocomplete="off"></b></td>
                </tr>


                <tr><td colspan="2">&nbsp;</td></tr>
                <tr>
                    <td></td>
                    <td>
                        <div style="width:27%; float:left;" class="stdbtnnrmWithFrameNoImage login-btn" onclick="javascript: if (disableButtonContent(this,false)) { logon()  } ">
                             Login
                        </div>
                    </td>
                </tr>

              </tbody></table>
            <br>
            <br>
            </div>
        </div>
 </form>

在此先感谢您的帮助!

0 个答案:

没有答案