php用curl抓網頁轉Big5到UTF-8範例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?
$webpage = $_GET["w"];
 
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, $webpage);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
$output = curl_exec($ch);
 
curl_close($ch);
 
echo iconv("Big5", "UTF-8", $output);
?>