采集转码以及模拟浏览器访问

<?php
header("content-type:text/html;charset=utf-8");
$url="http://www.sohu.com";
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; 4399Box.560; .NET4.0C; .NET4.0E)');
$a=file_get_contents($url);
echo mb_convert_encoding($a,'utf-8','gbk');

你可能感兴趣的:(采集转码以及模拟浏览器访问)