twitter sns クチコミ comments neta

2007/09/25 20:07:31

PHPのコードを書いてみる

<?php
require_once 'rhaco/Rhaco.php';
Rhaco::import('network.http.browser');
Rhaco::import('tag.model.SimpleTag');

class J_TotalMusic
{
    function get($url){
        $b = new Browser();
        $html = $b->get($url);
        $tag = new SimpleTag();
        $tag->set($html, 'body', true);

        $_html = mb_convert_encoding($html, 'utf-8', 'shift_jis');
        $artist = trim(preg_replace('/^.*?歌:(.*?)(\/|<).*?$/s', '$1', $_html));
        $words = trim(preg_replace('/^.*?詞:(.*?)(\/|<).*?$/s', '$1', $_html));
        $music = trim(preg_replace('/^.*?曲:(.*?)(\/|<).*?$/s', '$1', $_html));

        $title = new SimpleTag();
        $title->set($_html, 'title');
        $title = $title->getValue();
        $title = preg_replace('/^.*?J-Total Music−(.*?)(.*?$/', '$1', $title);

        foreach($tag->getIn('tt') as $tt){
            $content = $tt->getValue();
            break;
        }

        $content = preg_replace('|^.*?hp_d00\("(.*?)"\).*?$|is', '$1', $content);

        $lyric = urldecode(str_replace("\\x", '%', $content));
        $lyric = strip_tags($lyric, '<br>');
        $lyric = str_replace('<br>', "\n", preg_replace("/(\n|\r)/", "", $lyric));

        $ret = array(
            'title'  => $title,
            'artist' => $artist,
            'words'  => $words,
            'music'  => $music,
            'lyric'  => mb_convert_encoding($lyric, 'utf-8', 'shift_jis'),
        );
        return $ret;
    }
}

  • Add Comment

    name:

    comment:

    question:
    1 + 1 + 1= ?
    answer: