Quick actions

cmd+k|ctrl+k

Navigation

Languages

curl代理IP验证网页

Snippet info

Language

Php

Visibility

public

Author

mosi

Created

2019-01-11T06:04:17Z

Updated

2019-01-11T06:05:48Z

function curl_string ($url,$user_agent,$proxy){

       $ch = curl_init();
       curl_setopt ($ch, CURLOPT_PROXY, $proxy);
       curl_setopt ($ch, CURLOPT_URL, $url);
       curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
       curl_setopt ($ch, CURLOPT_COOKIEJAR, "c:\cookie.txt");
       curl_setopt ($ch, CURLOPT_HEADER, 1);
       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;

}

$url_page = "http://www.google.com";//目标URL
$user_agent = "Mozilla/4.0";//浏览器类
$proxy = "http://192.11.222.124:8000";//代理IP
$string = curl_string($url_page,$user_agent,$proxy);
echo $string;
INFO