/* @nifty辞書 */
$line = "";
//http://dictionary.nifty.com/word/%E7%A7%8B%E8%91%89%E5%8E%9F
//$fp=fsockopen("tool.nifty.com", 80, $errno, $errstr, 30);
$fp=fsockopen("dictionary.nifty.com", 80, $errno, $errstr, 30);
if(!$fp){
echo "$errstr ($errno) \n";
}else{
//$out="GET /oyakudachi/webapp/dictionary/search?book2=2&book3=3&book1=1&book0=0&word=".urlencode(mb_convert_encoding($word,"UTF-8","EUC-JP"))."&option=0&page=0&item= HTTP/1.1\r\n";
$out="GET /word/".urlencode(mb_convert_encoding($word,"UTF-8","EUC-JP"))." HTTP/1.1\r\n";
$out.="Host: dictionary.nifty.com\r\n";
$out.="Connection: Close\r\n\r\n";
fwrite($fp, $out);
$flg = FALSE;
while(!feof($fp)){
$line = fgets($fp, 1024);
$line = mb_convert_encoding($line,"EUC-JP","UTF-8");
if(mb_strpos($line,"全文を表示する")){
$line = "";
$flg = TRUE;
}
if(strpos($line, 'sponsorLink')){
break;
}
if($flg){
$line = str_replace("/word/","http://dictionary.nifty.com/word/",$line);
print $line;
}
}
fclose($fp);
}
?>
|
php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
|
|