Parse PHP to get the specified code of a remote Web page via cookies

Source: Internet
Author: User
Tags explode

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;
}
//Get the page code method
function Cut ($file, $from, $end) {
$message =explode ($from, $file);
$message =explode ($ End, $message [1]);
if ($mEssage[0] = = "")
{
$message [0] = "<font color= ' #ff0000 ' > Cannot get content </font>";
}
return $message [0];
}
//method of intercepting code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.