Example #1
0
function todays_book_title_and_photo_hatena()
{
    $book_list = json_decode(file_get_contents(BOOK_LIST), true);
    $title_src = '';
    $photo_src = '';
    foreach (todays_categories() as $category) {
        foreach ($book_list[$category] as $book) {
            $title_src .= "<a href='" . $book["url"] . "'target='_blank' class='book_title_hatena'>" . $book["title"] . "</a><br />";
            $photo_src .= "<a href='" . $book["url"] . "'target='_blank'><img title='" . $book["title"] . "'src='" . $book["img_url"] . "' class='book_photo_hatena'></a>";
        }
    }
    return array($title_src, $photo_src);
}
Example #2
0
function _exec()
{
    $urls = array();
    foreach (todays_categories() as $japanese) {
        $book_category = convert($japanese);
        echo "<br/>";
        echo '"' . $book_category . '": [';
        $pattern = '/a href="(.*?)"/';
        preg_match_all($pattern, file_get_html('http://miraitosho.hateblo.jp/entry/2014/04/22/225652')->find("div[id={$book_category}]", 0), $matches);
        foreach ($matches[1] as $url) {
            $html = file_get_html($url);
            $img_url = $html->find('.hatena-fotolife', 0)->src;
            $title = $html->find('.entry-title-link', 0)->innertext;
            echo '{';
            echo '"url": "' . $url . '",';
            echo '"title": "' . $title . '",';
            echo '"img_url": "' . $img_url . '"},';
        }
        echo '],';
    }
}