The code is as follows |
Copy Code |
function Getsourcecode ($q) {
Return @file_get_contents ($q); } Get web site source files with Curl function C_getpagecode ($c _url, $p _i=0) { $user _agent = "mozilla/4.0"; $proxy [0] = "http://211.155.231.208:80"; Zhejiang province Hangzhou Telecom IDC Room $proxy [1] = "http://210.51.10.197:8888"; Beijing Tong Tai Building netcom IDC Room $ch = Curl_init (); curl_setopt ($ch, Curlopt_proxy, $proxy [$p _i]); curl_setopt ($ch, Curlopt_url, $c _url); curl_setopt ($ch, curlopt_useragent, $user _agent); curl_setopt ($ch, Curlopt_cookiejar, "c:cookie.txt"); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_followlocation, 1); curl_setopt ($ch, Curlopt_timeout, 120); $result = curl_exec ($ch); Curl_close ($ch); return $result; } |
Instance Application
The code is as follows |
Copy Code |
$url = ' http://mb.111cn.net '; $body = Getsourcecode ($url); |
Echo $body; The mb.111cn.net content was collected locally
Let's take a look at that. Get web site source file Function example with Curl
echo C_getpagecode ($url);