[Perl] XML::FeedPP - RSS・RDF・Atomフィードの解析・生成・変換・結合
sudo apt-get install libxml-feedpp-mediarss-perl
#!/usr/bin/perl use strict; use XML::TreePP; use XML::FeedPP; my $feed = XML::FeedPP::RDF->new(); #RSS URL $feed->merge( "https://www.kimonolabs.com/api/rss/51jpctr2?&apikey=Hpo3uxKTJJA2W55lcnD7uHgvZ8shKiKQ&kimmodify=1" ); $feed->merge( "https://www.kimonolabs.com/api/rss/7lcb063a?&apikey=Hpo3uxKTJJA2W55lcnD7uHgvZ8shKiKQ&kimmodify=1" ); my $now = time(); #Sort $feed->sort_item(); $feed->title( "ehime np feed" ); $feed->description( "ehime np" ); $feed->link( "http://www.ehime-np.co.jp/news/local/" ); $feed->pubDate( $now ); print "Content-Type: text/xml; charset=UTF-8\n\n"; print $feed->to_string( "UTF-8" );
URI - (絶対や相対の)統一資源識別子(Uniform Resource Identifiers) - perldoc.jp
perldoc.jp
use strict; use warnings; use 5.010; use URI; use URI::QueryParam; my $link = 'http://news.google.com/news/url?sa=t&fd=R&ct2=us&usg=AFQjCNHchsgx4mKmj0EQV4cnXqUIdVX8QA&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779857450860&ei=d3rBVrj5CcfZ4QK84YeQCw&url=http://www.asahi.com/articles/ASJ2G315DJ2GPFIB001.html'; my $u = URI->new($link); say $u->scheme; # "http" say $u->host; # "news.google.com" say $u->port; # 80 say $u->path; # "/news/url" say $u->query; # "sa=t&fd=R&ct2=us&usg=AFQjCNHchsgx4mKmj0EQV4cnXqUIdVX8QA&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52779857450860&ei=d3rBVrj5CcfZ4QK84YeQCw&url=http://www.asahi.com/articles/ASJ2G315DJ2GPFIB001.html" say $u->fragment; # "" if($u->host eq "news.google.com") { say $u->query_param("url"); }