Parse php and use cookies to obtain the specified code of a remote webpage. Copy the code as follows: functionSteal ($ url, $ post_data) {$ header [] Accept: textvnd. wap. wml, *. *; $ user_agent1_illa4.0; $ follow_loc1; $ cookie_file.tmpc
The code is as follows:
Function Steal ($ url, $ post_data = ""){
// $ Header [] = "Accept: text/vnd. wap. wml ,*.*";
$ User_agent = "Mozilla/4.0 ";
$ Follow_loc = 1;
$ Cookie_file = "./tmp/cook.txt ";
$ Ch = @ curl_init ();
@ Curl_setopt ($ ch, CURLOPT_URL, $ url );
@ Curl_setopt ($ ch, CURLOPT_USERAGENT, $ user_agent );
@ Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie_file );
@ Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookie_file );
@ Curl_setopt ($ ch, CURLOPT_HEADER, $ header );
@ Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
@ Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, $ follow_loc );
@ Curl_setopt ($ ch, CURLOPT_TIMEOUT, 1000 );
If (trim ($ post_data )! = ""){
@ Curl_setopt ($ ch, CURLOPT_POST, 1 );
@ Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post_data );
}
$ Result = @ curl_exec ($ ch );
@ Curl_close ($ ch );
Return $ result;
}
// Method for obtaining webpage code
Function Cut ($ file, $ from, $ end ){
$ Message = explode ($ from, $ file );
$ Message = explode ($ end, $ message [1]);
If ($ message [0] = "")
{
$ Message [0] = "unable to get content ";
}
Return $ message [0];
}
// Method for intercepting code
The http://www.bkjia.com/PHPjc/327833.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327833.htmlTechArticle code is as follows: function Steal ($ url, $ post_data = "") {// $ header [] = "Accept: text/vnd. wap. wml ,*. * "; $ user_agent =" Mozilla/4.0 "; $ follow_loc = 1; $ cookie_file = ". /tmp/c...