<!--Curl's advanced use--><?PHP//analog Login Get cookie saved to PCHeader("content-type:text/html; Charset=utf-8 ");/*$cookie _file = Tempnam (' d:/', ' Cookie ');*/$cookie _file= ' D:/demo.txt ';$login _url= "http://www.php-z.com/member.php?mod=logging&action=login&loginsubmit=yes&loginhash=lj0cc& Inajax=1 ";/*$post _fields= "ormhash=354c7225&referer=http://www.php-z.com/&loginfield=username&username= Chenglin1994&password=chenglin1994&questionid=0&answer= ";*/$post _fields=Array(' ormhash ' = ' 354c7225 ', ' referer ' = ' http://www.php-z.com/', ' Loginfield ' = ' username ', ' username ' = ' chenglin1994 ', ' password ' = ' chenglin1994 ' ', ' questionid ' = ' 0 ', ' answer ' = ');//Submit a login form request$ch=curl_init ($login _url); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, curlopt_returntransfer,1); curl_setopt ($ch, curlopt_post,1); curl_setopt ($ch, Curlopt_postfields,$post _fields); curl_setopt ($ch, Curlopt_cookiejar,$cookie _file);//Store cookie data that is received after submissionEchoCurl_exec ($ch); Curl_close ($ch);//use cookies to view your personal center$url= ' Http://www.php-z.com/home.php?mod=space&do=friend ';$ch=curl_init ($url); curl_setopt ($ch, curlopt_header,0); curl_setopt ($ch, curlopt_returntransfer,1); curl_setopt ($ch, Curlopt_cookiefile,$cookie _file);//Use the cookie data obtained after submission to make parameters$contents=curl_exec ($ch); Curl_close ($ch);Echo $contents;
Excellent articles about Curl
PHP Curl Cookie Access Example (Standard capture program) and camouflage
19326893
19326893
PHP Curl application to implement the simulation login and capture the use of the method of explanation
Http://www.cnblogs.com/Zjmainstay/p/php-curl.html
PHP crawler (CURL) analog login get cookies and then use cookies to view your personal center