<"/>
<">

Home  >  Article  >  Backend Development  >  How to use DataReader to simulate the login process using scripts

How to use DataReader to simulate the login process using scripts

WBOY
WBOYOriginal
2016-07-29 08:35:11949browse

Look at the code of his login page to see which page he submitted to and what the variables are.

Copy the code The code is as follows:













name:
password:


< ;input type="button" name="submit" value="regest" >Copy the code The code is as follows:


        $postData = "username=your_name&password=your_password&Submit=Login";
        $posturl = "http://......../../login.jsp";
        $postUrl = parse_url($posturl);
        $host = $postUrl[host] ? $postUrl[host] : "";
        $port = $postUrl[port] ? $postUrl[port] : 80;
        $path = $postUrl[path] ? $postUrl[path] : "/";
        $fsp = fsockopen($host, $port, &$errno, &$errstr, 30);
        if(!$fsp){
                print "nopen socket failedn";
        }else{
                fwrite($fsp, "POST ".$path." HTTP/1.1rn");
                fwrite($fsp, "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*rn");
                fwrite($fsp, "Accept-Language: zh-cnrn");
                fwrite($fsp, "Content-Type: application/x-www-form-urlencodedrn");
                fwrite($fsp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)rn");
                fwrite($fsp, "Host:".$host."rn");
                fwrite($fsp, "Content-Length: ".strlen($postData)."rnrn");
                fwrite($fsp, $postData);
                $resp = "";
                do{
                        if(strlen($out=fread($fsp, 1024)) == 0) break;
                        $resp .= $out;
                }while(true);
                echo "

".nl2br($resp);
                fclose($fsp);
        }
?>

以上就介绍了DataReader使用 如何使用脚本模仿登陆过程,包括了DataReader使用方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn