1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
function get($url,$post_fields = null)
{
$ch = curl_init($url);
$ua = 'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Widows NT)';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
if($post_fields != null)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
}
$result = curl_exec($ch);
$dom = new DOMDocument();
@$dom->loadHTML($result);
curl_close($ch);
sleep(1);
return $dom;
} |
Partager