代码如下:
$url = "http://list.taobao.com/browse/cat-0.htm";
$html = file_get_contents($url);
echo '<Meta charset="UTF-8">';
$pattern='/\(.*?)\<\/a\>/';
preg_match_all($pattern,$html,$array,PREG_SET_ORDER);
foreach($array as $item) {
echo $item[1] . "=>" . mb_convert_encoding($item[2],'UTF-8','GB2312');
echo "
";
}
$html = file_get_contents($url);
echo '<Meta charset="UTF-8">';
$pattern='/\(.*?)\<\/a\>/';
preg_match_all($pattern,$html,$array,PREG_SET_ORDER);
foreach($array as $item) {
echo $item[1] . "=>" . mb_convert_encoding($item[2],'UTF-8','GB2312');
echo "
";
}