使用 cURL 填写外部表单?

发布于 2024-12-03 06:15:46 字数 163 浏览 1 评论 0原文

任何人都可以建议我如何使用我自己的变量填写 此表单 并使用 cURL/ 提交它PHP?是否可能,因为它似乎使用 JavaScipt 而不是正常的“post”来提交内容。感谢您的帮助。

Can anyone suggest how I could fill in this form with my own variables and submit it using cURL/PHP? Is it possible, as it seems to use JavaScipt instead of the normal 'post' to submit the content. Thanks for the help.

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

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

发布评论

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

评论(2

棒棒糖 2024-12-10 06:15:46

它使用 POST,但是它将表单数据提交到该页面上的多个 PHP 脚本。您最好下载 Firefox 版 TamperData 并检查与这些脚本的通信。
以下是我在 gist 上提交该表单时获得的信息。下面提供了一个示例会话:

15:13:13.371[1631ms][total 1631ms] Status: 200[OK]
POST http://tools.950buy.com/modules/2rss/2rss.php Load Flags[LOAD_BYPASS_CACHE  LOAD_BACKGROUND  ] Content Size[-1] Mime Type[text/html]
   Request Headers:
      Host[tools.950buy.com]
      User-Agent[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1]
      Accept[*/*]
      Accept-Language[en-us,en;q=0.5]
      Accept-Encoding[gzip, deflate]
      Accept-Charset[ISO-8859-1,utf-8;q=0.7,*;q=0.7]
      Connection[keep-alive]
      Content-Type[application/x-www-form-urlencoded; charset=UTF-8]
      X-Requested-With[XMLHttpRequest]
      Referer[http://tools.950buy.com/rss-submit/]
      Content-Length[117]
      Cookie[__utma=201106987.2026695530.1315001346.1315001346.1315001346.1; __utmb=201106987.3.10.1315001346; __utmz=201106987.1315001346.1.1.utmcsr=stackoverflow.com|utmccn=(referral)|utmcmd=referral|utmcct=/questions/7289661/fill-in-an-external-form-using-curl; __utmc=201106987]
      Pragma[no-cache]
      Cache-Control[no-cache]
   Post Data:
      url[http://www.test.com]
      title[Test Title]
      WebSite[http://www.test.com]
      email[[email protected]]
      description[Test Description]
   Response Headers:
      Date[Fri, 02 Sep 2011 22:13:16 GMT]
      Server[Apache]
      X-Powered-By[PHP/5.2.17]
      Vary[Accept-Encoding]
      Connection[close]
      Transfer-Encoding[chunked]
      Content-Type[text/html; charset=utf-8]

It is using POST, however it submits the form data to several PHP scripts on that page. You would be best off downloading TamperData for Firefox and examining the communication to those scripts.
Here is the information I got when submitting that form on a gist. An example session is provided below:

15:13:13.371[1631ms][total 1631ms] Status: 200[OK]
POST http://tools.950buy.com/modules/2rss/2rss.php Load Flags[LOAD_BYPASS_CACHE  LOAD_BACKGROUND  ] Content Size[-1] Mime Type[text/html]
   Request Headers:
      Host[tools.950buy.com]
      User-Agent[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20100101 Firefox/6.0.1]
      Accept[*/*]
      Accept-Language[en-us,en;q=0.5]
      Accept-Encoding[gzip, deflate]
      Accept-Charset[ISO-8859-1,utf-8;q=0.7,*;q=0.7]
      Connection[keep-alive]
      Content-Type[application/x-www-form-urlencoded; charset=UTF-8]
      X-Requested-With[XMLHttpRequest]
      Referer[http://tools.950buy.com/rss-submit/]
      Content-Length[117]
      Cookie[__utma=201106987.2026695530.1315001346.1315001346.1315001346.1; __utmb=201106987.3.10.1315001346; __utmz=201106987.1315001346.1.1.utmcsr=stackoverflow.com|utmccn=(referral)|utmcmd=referral|utmcct=/questions/7289661/fill-in-an-external-form-using-curl; __utmc=201106987]
      Pragma[no-cache]
      Cache-Control[no-cache]
   Post Data:
      url[http://www.test.com]
      title[Test Title]
      WebSite[http://www.test.com]
      email[[email protected]]
      description[Test Description]
   Response Headers:
      Date[Fri, 02 Sep 2011 22:13:16 GMT]
      Server[Apache]
      X-Powered-By[PHP/5.2.17]
      Vary[Accept-Encoding]
      Connection[close]
      Transfer-Encoding[chunked]
      Content-Type[text/html; charset=utf-8]
爱的那么颓废 2024-12-10 06:15:46

它是通过 JavaScript 完成的。它为页面上的每个复选框提交一个发布请求

这些是您需要复制的功能:

function ActionSubmit(){
    var Posturl="/modules/";
    var url=$("#url").val();
    var title=$("#title").val();
    var WebSite=$("#WebSite").val();
    var email=$("#email").val();
    var description=$("#description").val();
    var data='url='+url+"&title="+title+"&WebSite="+WebSite+"&email="+email+"&description="+description;
    var str="";
    if (formVaildate()){
         $("[name='checkbox'][checked]").each(function(){
             str=$(this).val();
             strs=str.toLowerCase()
             strs=strs.replace("-","_");
             Posturl= Posturl+strs+"/"+strs+".php";
             URLSubmit(Posturl,data,str);
             Posturl="/modules/";
       });
    }
}
function URLSubmit(url,data,str){   
    $.ajax({
            url: url,
            type: 'POST',
            data: data,
            beforeSend:function(){
                    $("#"+str+"_State").html("Please wait...");
                },
            complete:function(){
                    $("#"+str+"_State").html("<img src='/images/right.gif'>");
                },
            success:function(msg){
               if (msg!=""){            
                $("#"+str+"_State").html("<img src='/images/right.gif'>");
               }else{
                   alert(msg);
               }
              }
        });

}

It is done via javascript. It submits a post request for each checkbox on the page

These are the functions you need to replicate:

function ActionSubmit(){
    var Posturl="/modules/";
    var url=$("#url").val();
    var title=$("#title").val();
    var WebSite=$("#WebSite").val();
    var email=$("#email").val();
    var description=$("#description").val();
    var data='url='+url+"&title="+title+"&WebSite="+WebSite+"&email="+email+"&description="+description;
    var str="";
    if (formVaildate()){
         $("[name='checkbox'][checked]").each(function(){
             str=$(this).val();
             strs=str.toLowerCase()
             strs=strs.replace("-","_");
             Posturl= Posturl+strs+"/"+strs+".php";
             URLSubmit(Posturl,data,str);
             Posturl="/modules/";
       });
    }
}
function URLSubmit(url,data,str){   
    $.ajax({
            url: url,
            type: 'POST',
            data: data,
            beforeSend:function(){
                    $("#"+str+"_State").html("Please wait...");
                },
            complete:function(){
                    $("#"+str+"_State").html("<img src='/images/right.gif'>");
                },
            success:function(msg){
               if (msg!=""){            
                $("#"+str+"_State").html("<img src='/images/right.gif'>");
               }else{
                   alert(msg);
               }
              }
        });

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