google trends to_irc

Download Google trends to_irc

If you can't read please download the document

Upload: rarere

Post on 16-Apr-2017

1.433 views

Category:

Documents


2 download

TRANSCRIPT

PowerPoint Presentation

Perl

@rarere

4

Perl

Google Trends
IRC
Perl

Pla(ry

Google Trends

iGoogle

http://www.google.co.jp/trends

IRC

2ch


#LUCK

2ch#LUCK: Linux Users group ChugoKu

xxxxxx> http://www.nikkansports.com/entertainment/news/f-et-tp0-20100731-660250.html
xxxxxx>
rarere< Google
xxxxxx>
rarere< iGoogle
xxxxxx> twitter
rarere<
rarere< 1
xxxxxx> iGoogle
rarere< Plagger
xxxxxx> 1


::

RSSHTMLIRC

GoogleIRCPerl

GoogleHTML

Perl

CPAN

(13)

#/usr/bin/perl -w

use strict;
use warnings;
use Time::Piece ();
use Time::Seconds;
use LWP::UserAgent;
use POE qw(Component::IRC);
use Encode qw(from_to);

Google

http://www.google.co.jp/trends/hottrends?sa=X&date=2010-9-29

2

RSS

Perl5.10Time::PieceTime::Seconds

use Time::Piece ();use Time::Seconds;

my $t = Time::Piece::localtime();

# 1$t -= ONE_DAY;

my $year = $t->year;my $mon = $t->mon;my $mday = $t->mday;

my $url = "http://www.google.co.jp/trends/hottrends?sa=X&date=$year-$mon-$mday";

HTML

HTML LWP::UserAgent;

# HTMLmy $ua = LWP::UserAgent->new;my $response = $ua->get($url);my $content;if ($response->is_success) { $content = $response->content;} else { die($response->status_line);}

# HTMLmy @html = split( /\n/, $content);my $i = 0;foreach my $line (@html) { if ($line =~ m/(\d+\.).*(.*)/) { push(@trends, $1.$2); $i++; } if ( $i == 10 ) { last; }}

2010

IRCCPAN
POE::Component::IRC

sub irc_001 { my $sender = $_[SENDER]; my $irc = $sender->get_heap();

print "Connected to ", $irc->server_name(), "\n";

$irc->yield( join => $_ ) for @channels;

my $msg = join(' ', @trends); $msg = "Google Trends: ".$msg; from_to($msg, 'utf-8', 'iso-2022-jp'); $irc->yield( notice => @channels[0] => $msg ); $irc->yield( shutdown => $server );

return ;}

IRCuse Encode qw(from_to);

cron8

IRC

use Encode qw(from_to);
from_to($msg, 'utf-8', 'iso-2022-jp');

IRC(512)

10