开发者

Fill in an external form using cURL?

开发者 https://www.devze.com 2023-04-01 22:11 出处:网络
Can anyone suggest how I could fill in this form with my own variable开发者_C百科s and submit it using cURL/PHP? Is it possible, as it seems to use JavaScipt instead of the normal \'post\' to submit t

Can anyone suggest how I could fill in this form with my own variable开发者_C百科s 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.


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[test@test.com]
      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 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);
               }
              }
        });

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号