日記/2014-10-08
をテンプレートにして作成
ホーム
検索
最終更新
テスト
リンク
ヘルプ
新規
pukiwiki-official
pukiwiki-dev
ヘルプ
プラグインヘルプ
開始行:
**Dstarusers.orgのlist加工 [#ad00f95e]
USTRUST系のログサイトhttp://http://www.dstarusers.org/ の...
+Webページからの切り取り。最初っから時間でソートした画面...
-- get_parse.pl --
use strict;
use warnings;
use LWP::UserAgent;
use HTML::TreeBuilder;
# urlを指定する
my $url = 'http://www.dstarusers.org/?lastheardsort=4';
# IE8のフリをする
my $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Win...
# LWPを使ってサイトにアクセスし、HTMLの内容を取得する
my $ua = LWP::UserAgent->new('agent' => $user_agent);
my $res = $ua->get($url);
my $content = $res->content;
# HTML::TreeBuilderで解析する
my $tree = HTML::TreeBuilder->new;
$tree->parse($content);
# DOM操作してトピックの部分だけ抜き出す。
# <div id='topicsfb'><ul><li>....の部分を抽出する
open (OUT, ">> dstarlist.txt");
my @items = $tree->look_down('class', 'systemtbl')->fin...
print OUT $_->as_text.":" for @items;
close(OUT);
+抽出項目を指定して再リスト化
-- bunkai.sh --
#!/bin/bash
if [ -f /home/moto/dstarlist.txt ]; then
rm -f /home/moto/dstarlist.txt
fi
if [ -f /home/moto/dstlistx.txt ]; then
rm -f /home/moto/dstlistx.txt
fi
/usr/bin/perl /home/moto/get_parse.pl
nkf -a /home/moto/dstarlist.txt > dstlistx.txt
if [ -f /home/moto/dslist.txt ]; then
rm -f /home/moto/dslist.txt
fi
N=5
while :
do
M=`expr $N + 5`
X="$N-$M"
#echo "$N"
LS="/bin/cat /home/moto/dstlistx.txt | /usr/bin/cut -d \...
eval $LS
N=`expr $N + 6`
if test $N -gt 1500 ; then
break
fi
done
cat dslist.txt | grep -e "^7\|^J\|REF008\|REF047"
+応用
例えば、アクセス時間で新しい方から7局をlist UP する場合は
$ ./bunkai.sh | head -7
ide character in print at /home/moto/get_parse.pl line 2...
JP3KVE:10/08/14 09:30:13 UTC:ZL1VHD B 440 MHz:Auckland, ...
JA9MIZ A:10/08/14 09:26:38 UTC:JP9YEI A 1.2GHz:Nanto, To...
JE1IXA:10/08/14 09:12:51 UTC:JP1YJQ A 1.2GHz:Chiba Inage...
JO1WID:10/08/14 09:00:51 UTC:JP1YDS A 1.2GHz:Katori, Chi...
JL1LTE:10/08/14 09:00:44 UTC:JP1YDS A 1.2GHz:Katori, Chi...
JE3HCZ:10/08/14 08:47:01 UTC:REF047 C 2 Meters DVD:Japan
JK1MNC:10/08/14 08:41:36 UTC:JP1YJT A 1.2GHz:Yachimata, ...
+phpで作成
ブラウザで開けるタイプにしてみた。UTC 表示に JST も追加表...
-- wwdst.php --
<html>
<head>
<meta http-equiv="refresh" content="60">
<meta http-equiv="Content-Type" content="text/html; char...
<title>DstarUsers.org List(JP)</title>
</head>
<body>
<?
$lines = file("http://www.dstarusers.org/?lastheardsort=...
$ct = count($lines) - 30;
print "<table border=4 width=850 align=left>\r\n";
print "<tr><th colspan=4>---------- <b>view-source:...
print "<tr bgcolor='#cccccc'><th>Callsign</th>";
print "<th>Time Heard<BR>MM/DD/YY UTC / JST&n...
print "<th>Reporting Node &...
print "<th>Unique callsigns heard in the last hour</th><...
$i = 169;
$hed = "http://www.dstarusers.org/viewrepeater.php";
while( $i < $ct ){
if(strpos($lines[$i],'google') <= 0 ){
if(strpos($lines[$i],'/tr>') <= 0 ){
if(substr($lines[$i],8,4) == "<b>7" ){
print $lines[$i];
$i++;
$jst1 = substr($lines[$i],17,2) + 9;
if($jst1 >=24 ){
$jst1 = $jst1 - 24;
}
$jst1 = "/ ".$jst1.substr($lines[$i],19,6);
$out1 = str_replace('UTC',$jst1,$lines[$i]);
print $out1;
$i++;
$lines[$i] = str_replace('/viewrepeater.php',$hed...
if(strpos($lines[$i],'1.2GHz') > 0 ){
$out3 = str_replace('1.2GHz','440 MHz',$lines[$...
print $out3;
}elseif(strpos($lines[$i],'440') > 0 ){
$out3 = str_replace('440 MHz','1.2GHz',$lines[$...
print $out3;
}else{
print $lines[$i];
}
$i++;
print $lines[$i]."</tr>";
$i++;
}
if(substr($lines[$i],8,4) == "<b>J" ){
print $lines[$i];
$i++;
$jst1 = substr($lines[$i],17,2) + 9;
if($jst1 >=24 ){
$jst1 = $jst1 - 24;
}
$jst1 = "/ ".$jst1.substr($lines[$i],19,6);
$out1 = str_replace('UTC',$jst1,$lines[$i]);
print $out1;
$i++;
$lines[$i] = str_replace('/viewrepeater.php',$hed...
if(strpos($lines[$i],'1.2GHz') > 0 ){
$out3 = str_replace('1.2GHz','440 MHz',$lines[$...
print $out3;
}elseif(strpos($lines[$i],'440') > 0 ){
$out3 = str_replace('440 MHz','1.2GHz',$lines[$...
print $out3;
}else{
print $lines[$i];
}
$i++;
print $lines[$i]."</tr>";
$i++;
}
}
}
$i++;
}
?>
</body>
</html>
+表示例
&ref(wwdst_sample.jpg,,80%);
#clear
#comment
#navi(日記)
終了行:
**Dstarusers.orgのlist加工 [#ad00f95e]
USTRUST系のログサイトhttp://http://www.dstarusers.org/ の...
+Webページからの切り取り。最初っから時間でソートした画面...
-- get_parse.pl --
use strict;
use warnings;
use LWP::UserAgent;
use HTML::TreeBuilder;
# urlを指定する
my $url = 'http://www.dstarusers.org/?lastheardsort=4';
# IE8のフリをする
my $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Win...
# LWPを使ってサイトにアクセスし、HTMLの内容を取得する
my $ua = LWP::UserAgent->new('agent' => $user_agent);
my $res = $ua->get($url);
my $content = $res->content;
# HTML::TreeBuilderで解析する
my $tree = HTML::TreeBuilder->new;
$tree->parse($content);
# DOM操作してトピックの部分だけ抜き出す。
# <div id='topicsfb'><ul><li>....の部分を抽出する
open (OUT, ">> dstarlist.txt");
my @items = $tree->look_down('class', 'systemtbl')->fin...
print OUT $_->as_text.":" for @items;
close(OUT);
+抽出項目を指定して再リスト化
-- bunkai.sh --
#!/bin/bash
if [ -f /home/moto/dstarlist.txt ]; then
rm -f /home/moto/dstarlist.txt
fi
if [ -f /home/moto/dstlistx.txt ]; then
rm -f /home/moto/dstlistx.txt
fi
/usr/bin/perl /home/moto/get_parse.pl
nkf -a /home/moto/dstarlist.txt > dstlistx.txt
if [ -f /home/moto/dslist.txt ]; then
rm -f /home/moto/dslist.txt
fi
N=5
while :
do
M=`expr $N + 5`
X="$N-$M"
#echo "$N"
LS="/bin/cat /home/moto/dstlistx.txt | /usr/bin/cut -d \...
eval $LS
N=`expr $N + 6`
if test $N -gt 1500 ; then
break
fi
done
cat dslist.txt | grep -e "^7\|^J\|REF008\|REF047"
+応用
例えば、アクセス時間で新しい方から7局をlist UP する場合は
$ ./bunkai.sh | head -7
ide character in print at /home/moto/get_parse.pl line 2...
JP3KVE:10/08/14 09:30:13 UTC:ZL1VHD B 440 MHz:Auckland, ...
JA9MIZ A:10/08/14 09:26:38 UTC:JP9YEI A 1.2GHz:Nanto, To...
JE1IXA:10/08/14 09:12:51 UTC:JP1YJQ A 1.2GHz:Chiba Inage...
JO1WID:10/08/14 09:00:51 UTC:JP1YDS A 1.2GHz:Katori, Chi...
JL1LTE:10/08/14 09:00:44 UTC:JP1YDS A 1.2GHz:Katori, Chi...
JE3HCZ:10/08/14 08:47:01 UTC:REF047 C 2 Meters DVD:Japan
JK1MNC:10/08/14 08:41:36 UTC:JP1YJT A 1.2GHz:Yachimata, ...
+phpで作成
ブラウザで開けるタイプにしてみた。UTC 表示に JST も追加表...
-- wwdst.php --
<html>
<head>
<meta http-equiv="refresh" content="60">
<meta http-equiv="Content-Type" content="text/html; char...
<title>DstarUsers.org List(JP)</title>
</head>
<body>
<?
$lines = file("http://www.dstarusers.org/?lastheardsort=...
$ct = count($lines) - 30;
print "<table border=4 width=850 align=left>\r\n";
print "<tr><th colspan=4>---------- <b>view-source:...
print "<tr bgcolor='#cccccc'><th>Callsign</th>";
print "<th>Time Heard<BR>MM/DD/YY UTC / JST&n...
print "<th>Reporting Node &...
print "<th>Unique callsigns heard in the last hour</th><...
$i = 169;
$hed = "http://www.dstarusers.org/viewrepeater.php";
while( $i < $ct ){
if(strpos($lines[$i],'google') <= 0 ){
if(strpos($lines[$i],'/tr>') <= 0 ){
if(substr($lines[$i],8,4) == "<b>7" ){
print $lines[$i];
$i++;
$jst1 = substr($lines[$i],17,2) + 9;
if($jst1 >=24 ){
$jst1 = $jst1 - 24;
}
$jst1 = "/ ".$jst1.substr($lines[$i],19,6);
$out1 = str_replace('UTC',$jst1,$lines[$i]);
print $out1;
$i++;
$lines[$i] = str_replace('/viewrepeater.php',$hed...
if(strpos($lines[$i],'1.2GHz') > 0 ){
$out3 = str_replace('1.2GHz','440 MHz',$lines[$...
print $out3;
}elseif(strpos($lines[$i],'440') > 0 ){
$out3 = str_replace('440 MHz','1.2GHz',$lines[$...
print $out3;
}else{
print $lines[$i];
}
$i++;
print $lines[$i]."</tr>";
$i++;
}
if(substr($lines[$i],8,4) == "<b>J" ){
print $lines[$i];
$i++;
$jst1 = substr($lines[$i],17,2) + 9;
if($jst1 >=24 ){
$jst1 = $jst1 - 24;
}
$jst1 = "/ ".$jst1.substr($lines[$i],19,6);
$out1 = str_replace('UTC',$jst1,$lines[$i]);
print $out1;
$i++;
$lines[$i] = str_replace('/viewrepeater.php',$hed...
if(strpos($lines[$i],'1.2GHz') > 0 ){
$out3 = str_replace('1.2GHz','440 MHz',$lines[$...
print $out3;
}elseif(strpos($lines[$i],'440') > 0 ){
$out3 = str_replace('440 MHz','1.2GHz',$lines[$...
print $out3;
}else{
print $lines[$i];
}
$i++;
print $lines[$i]."</tr>";
$i++;
}
}
}
$i++;
}
?>
</body>
</html>
+表示例
&ref(wwdst_sample.jpg,,80%);
#clear
#comment
#navi(日記)
ページ名: