EDGE Now! ブロガーリストを表組みに変換
スポンサードリンク
EDGE Now! のブロガーリスト、アイコンを選択しないと詳細がわかない仕組みなので、せっかくXMLがでていますので表組で表示します。
Filename: bloggerslist.cgi
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); use Data::Dumper; use HTML::Template; use LWP::Simple; use URI; use utf8; use XML::Simple; binmode STDOUT => ':utf8'; my $tmpl_html = <<'END_OF_HTML'; <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>EDGE Now! Bloggers List</title> <meta http-equiv="content-script-type" content="text/javascript" /> <meta http-equiv="content-style-type" content="text/css" /> <link rel="index" href="./" /> <link rev="made" href="mailto:aab61120@pop12.odn.ne.jp" /> <link rel="shortcut icon" href="favicon.ico" /> <link rel="stylesheet" href="default.css" type="text/css" /> <style type="text/css"> body { text-align: center; } img { border: 0px; } div#contents { width: 700px; margin: 0px auto; text-align: left; } table.userlist { width: 100%; border-collapse: collapse; } .userlist thead th { background-color: #333; color: white; text-align: center; } .userlist tbody th { background-color: white; text-align: center; } .userlist tbody th { background-color: #f8f8f8; } .userlist tbody .even th { background-color: #e0e0e0; } .userlist tbody .even td { background-color: #e8e8e8; } .posted em { background-color: #fff0f0; font-weight: bold; font-style: normal; } .posted em a, .posted em a:link, .posted em a:visited, .posted em a:hover, .posted em a:active { color: #f66; font-weight: bold; font-style: normal; } .posted strong { background-color: #fcc; font-weight: bold; font-style: normal; display: inline; } .posted strong a, .posted strong a:link, .posted strong a:visited, .posted strong a:hover, .posted strong a:active { color: red; font-weight: bold; font-style: normal; text-decoration: none; } .posted a, .posted a:link, .posted a:visited, .posted a:hover, .posted a:active { text-decoration: none; color: blue; } </style> </head> <body> <div id="contents"> <h1>EDGE Now! Bloggers List</h1> <p> Adobe EDGE Now!のブロガーランキングで表示される Bbloggers Listの一覧表示です。 </p> <p> <a href="http://edgenow.jp/" target="_blank">EDGE Now!</a> </p> <p> 現在の最大id: <tmpl_var name="maxid" escape="html">人<br /> ユーザリストの人数: <tmpl_var name="maxcontents" escape="html">人<br /> 退会した人の人数: <tmpl_var name="diff" escape="html">人<br /> </p> <p> page: <tmpl_var name="page" escape="html"> pager: <tmpl_loop name="loop_pager"> <tmpl_if name="isnowpage"> <tmpl_var name="page" escape="html"> <tmpl_else> <a href="bloggerslist.cgi?page=<tmpl_var name="page" escape="html">"> <tmpl_var name="page" escape="html"></a> </tmpl_if> </tmpl_loop> </p> <table border="0" cellpadding="0" cellspacing="0" summary="EDGE Now! Bloggers List" class="userlist"> <thead> <tr> <th abbr="id"> id </th> <th abbr="blog"> blog </th> <th abbr="name" style="width:90px;"> name </th> <th abbr="SBMs" style="width:80px;"> SBMs </th> </tr> </thead> <tbody> <tmpl_loop name="loop_masks"> <tr<tmpl_unless name="__odd__"> class="even"</tmpl_unless>> <th abbr="id"> <tmpl_var name="id" escape="html"> </th> <td> <span style="font-weight: bold;"> <tmpl_var name="title" escape="html"> </span> <br /> <a href="<tmpl_var name="url" escape="html">" target="_blank"> <tmpl_var name="url" escape="html"></a> </td> <td style="text-align: center;"> <a href="<tmpl_var name="url" escape="html">" style="text-decoration: none;" target="_blank"> <img src="http://edgenow.jp/member/pic/<tmpl_var name="id" escape="html">.gif" alt="<tmpl_var name="name" escape="html">" width="50" height="50" /><br /> <tmpl_var name="name" escape="html"></a> </td> <td class="posted"> <script type="text/javascript" charset="UTF-8" src="http://labo.dtpwiki.jp/sbm/check.cgi?url=<tmpl_var name="url" escape="html">&mode=js"></script> </td> </tr> </tmpl_loop> </tbody> </table> </div> </body> </html> END_OF_HTML my $itemsparpage = 40; my $q = CGI->new(); my $page = $q->param('page') || 0; my $ref = get_EDGENow(0); my $maxid = $ref->{bloggerListList}->[0]->{blogger}->[0]->{id}; $ref = get_EDGENow($page); my $maxcontents = $ref->{module}->{maxcontents}->{count}; my $maxpage = int ($maxcontents / $itemsparpage); my $pagelist; for ( 0 .. $maxpage ) { push @$pagelist, { page => $_, isnowpage => $_ == $page, }; } my $showlist; foreach my $item ( @{$ref->{bloggerListList}->[0]->{blogger} } ) { my $temp_item = { id =>$item->{id}, url =>$item->{url}->[0], title =>$item->{title}->[0], name => $item->{name}->[0], }; push @$showlist, $temp_item; } my $tmpl = HTML::Template->new( scalarref => \$tmpl_html, die_on_bad_params => 0, loop_context_vars => 1, ); $tmpl->param( 'loop_masks' => $showlist, 'loop_pager' => $pagelist, 'maxid' => $maxid, 'maxcontents' => $maxcontents, 'diff' => $maxid - $maxcontents, 'page' => $page, ); print $q->header( -type => 'text/html', -charset => 'UTF-8',); print $tmpl->output(); exit; sub get_EDGENow { my $page = shift; my $proxy = 'http://edgenow.jp/xml/bloggerList.php'; my $uri = URI->new( $proxy ); $uri->query_form( page => $page, ) if $page; my $xml = get( $uri->as_string ); my $xs = new XML::Simple(); my $ref = $xs->XMLin( $xml, forcearray => 1 ); return $ref; } __END__
スポンサードリンク
トラックバック(0)
トラックバックURL: http://blog.dtpwiki.jp/MTOS/mt-tb.cgi/2423
コメントする