çªç¶ã§ãããPerlã§ã¯ã¦ãªããã¯ãã¼ã¯ãåä¿¡ãã¦ããã£ã¼ãã解æãããã¨æã£ãã¨ãã®æ®éª¸ããã©ãã®æ¥ã ã£ã¦ã®ã«ä½ãã£ã¦ãã®ï¼ã¨ãã件ã«ã¤ãã¦ã¯ã¤ã£ããã§ã¯ããã¾ããã
# ãã¦ã³ãã¼ã my $req = HTTP::Request->new(GET => $feed_url); my $res = LWP::UserAgent->new->request($req)->content; # ãã£ã¼ããéã my $feed = XML::Atom::Feed->new(\$res); my @entries = $feed->entries; print FILE "entries of $feed_url\n"; foreach my $entry(@entries){ my %hash; $hash{title} = $entry->title; my @rellink = grep {$_->rel eq 'related'} $entry->link; $hash{link} = $rellink[0]->href if(@rellink); $hash{body} = $entry->summary; $hash{issued}= $entry->issued; print FILE "\ttitle: $hash{title}\n"; print FILE "\tlink: $hash{link}\n"; print FILE "\tsummary: $hash{body}\n"; print FILE "\tissued: $hash{issued}\n"; print FILE "\n"; } my @feedlink = grep {$_->rel eq 'next'} $feed->link; $feed_url = $feedlink[0]->href if(@feedlink); print FILE "nextfeed: $feed_url \n\n"; print "finished next $feed_url \n\n";
$feed_urlã¨ããã®ã¯ãè¦ã¦ã®ã¨ãããã£ã¼ãã®URLã§ãã
ã¾ããXML::Atom::Feedã使ãã°ããããªæãã§ããã¾ãXMLãæèããã«ãããããªãã¨ãã§ãã¾ãã ã¨ãããã¨ã¯ããåããã¾ãããXML::Atom::Utilã¨ãããã®ã使ãã°issuedãPerlã¿ã¤ã ã«å¤æã§ããããã§ããããã£ã¡ã¯åãã¾ããã§ããã(å
é¨ã§ä½¿ç¨ãã¦ããDateTime.pmããã©ããã§ã¨ã©ã¼ãèµ·ããã¦ããæ§å)ã
注æããªããã°ãªã¨æã£ãã®ã¯ãã½ã¼ã¹å
ã§2ååºã¦ããgrepã®é¨åã
çµæã¯ä¸åããæå¾
ãã¦ããªãã®ã§ãå¥ã«ã¹ã«ã©ã¼ã³ã³ããã¹ãã§ããããã¨æã£ãã大ééããgrepã®æ»ãå¤ã¯ãã¹ã«ã©ã¼ã³ã³ããã¹ãã®å ´åçµæã®åæ°ã«ãªã£ã¦ãã¾ãã®ã§ããããããé¢æ°ãã¡ããã¡ãããã£ããããã®ããPerlã®çã®ããã¨ããã§ãã*1ã
ã¯ã¦ãªå´ã«ã¯çµæ§è² è·ããããã¾ããâ¦ãblummyã®ããã«ãã¯ãªãã¯ããã ãã§ããã¯ãã¼ã¯ãåå¾ãã¿ã°ãã¨ã«åé¡ãã¦ããªã³ã¯ããé£ã¹ãããã«ãã¦ããããããªããã¯ãã¼ã¯ã¬ãããããã¨æ¥½ã ãªãâ¦ã¨æã£ããã§ããã©ããããããã®ã¯ãã£ã±ãå¥ã½ããã§ä½ããªããã ãããªãã
ãªããããã§ã¯ã½ã¼ã¹ãä¸é¨ããããã¦ãã¾ãããããã以å¤ã®é¨åã®ã½ã¼ã¹ã¯ãåèã«ãã¾ããã
æè¿ã¯POSTのサンプルも他の人によってあげられているããã§ãã®ã§ãåèã«ãªãããã§ãã
æå¾ã«ãå½ç¶ãªãã
- XML::Atom以ä¸ã¢ã¸ã¥ã¼ã«(XML::Atomã®ã¢ã¼ã«ã¤ãã«å ¥ã£ã¦ããã®)
- XML::XPath以ä¸ã¢ã¸ã¥ã¼ã«(XML::Pathã®ã¢ã¼ã«ã¤ãã«å ¥ã£ã¦ããã®)
ãå¿ è¦ã§ãã®ã§ãã¤ã³ã¹ãã¼ã«ããã¦ãªãå ´åã¯CPANãããããå ¥æãã¦ãã ããã
*1:ãªãã¡ã¬ã³ã¹ã«ãªãã£ãã®ã§å¿ãã¦ã¾ãããããã®ã¨ãçµæã¯@_ã«ã§ãå ¥ã£ã¦ããããããªã