{"id":256,"date":"2020-06-06T16:39:11","date_gmt":"2020-06-06T07:39:11","guid":{"rendered":"https:\/\/pocolog.bass-world.net\/tech\/?p=256"},"modified":"2020-06-06T16:39:11","modified_gmt":"2020-06-06T07:39:11","slug":"rss-crowler-2020","status":"publish","type":"post","link":"https:\/\/pocolog.bass-world.net\/tech\/2020\/rss-crowler-2020\/","title":{"rendered":"RSS \u30af\u30ed\u30fc\u30e9\u30012020 \u5e74\u7248"},"content":{"rendered":"\n<p>\u30af\u30e9\u30a6\u30c9\u30b5\u30fc\u30d0\u3092 GMO \u30af\u30e9\u30a6\u30c9\u304b\u3089 Amazon Web Service \u306e EC2 \u306b\u79fb\u884c\u3059\u308b\u306b\u5f53\u305f\u3063\u3066\u3001\u4eca\u307e\u3067\u306e RSS \u30af\u30ed\u30fc\u30e9\u3092\u4fee\u6b63\u3002<br>\u6b63\u76f4\u3082\u306e\u3059\u3054\u3044\u4fee\u6b63\u3057\u305f\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-preformatted\"><em>#!\/usr\/bin\/perl<\/em>\n\nuse strict;\nuse warnings;\nuse Encode;\nuse LWP::Simple;\nuse XML::RSS;\nuse Time::Local;\nuse HTTP::Date;\nuse DateTime::Format::HTTP;\n<em>#binmode(STDOUT, \":utf8\");<\/em>\n\n<strong>my<\/strong> @url = (\n\"https:\/\/pocolog.bass-world.net\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/tech\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/book\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/gadgets\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/music\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/cars\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/creditcard\/feed\/\",\n\"https:\/\/pocolog.bass-world.net\/travel\/feed\/\"\n);\n<strong>my<\/strong> $line = \"\";\n\nforeach <strong>my<\/strong> $url(@url){\n<strong>my<\/strong> $document = LWP::Simple::get($url) or die();\n<strong>my<\/strong> $rss = XML::RSS-&gt;new;\n$rss-&gt;parse($document);\n$line .= \"&lt;h3&gt;&lt;a href = '\" . $rss-&gt;channel-&gt;{link} . \"'&gt;\" . $rss-&gt;channel-&gt;{title} . \"&lt;\/a&gt;&lt;\/h3&gt;\\n\";\n$line .= \"&lt;p&gt;\" . $rss-&gt;channel-&gt;{description} . \"&lt;\/p&gt;\\n\";\n\n<strong>my<\/strong> $counter = 0;\n$line .= \"&lt;ul&gt;\\n\";\n\nfor(@{$rss-&gt;{items}}){\n$counter++;\nif(!$_){\nlast;\n}\nif($counter &gt; 5){\nlast;\n}\n\n<strong>my<\/strong> $datetime = $_-&gt;{pubDate};\nif(!$datetime){\nlast;\n}\n\n<strong>my<\/strong> $dt = DateTime::Format::HTTP-&gt;parse_datetime($datetime);\n$dt-&gt;set_time_zone('Asia\/Tokyo');\n<strong>my<\/strong> $date = $dt-&gt;year . '.' . $dt-&gt;month . '.' . $dt-&gt;day;\n$line .= \"&lt;li&gt;\" . $date;\n$line .= \" - \";\n$line .= \"&lt;a href = '\" . $_-&gt;{link} . \"'&gt;\";\n$line .= $_-&gt;{title} . \"&lt;\/a&gt;&lt;\/li&gt;\\n\";\n}\n$line .= \"&lt;\/ul&gt;\\n\";\n}\nprint encode('utf-8', $line);\n\n<em>#open(BLOG, \"&gt;\", \".\/www\/blogdata.html\");<\/em>\n<em>#print BLOG $line;<\/em>\n<em>#close(BLOG);<\/em>\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30af\u30e9\u30a6\u30c9\u30b5\u30fc\u30d0\u3092 GMO \u30af\u30e9\u30a6\u30c9\u304b\u3089 Amazon Web Service \u306e EC2 \u306b\u79fb\u884c\u3059\u308b\u306b\u5f53\u305f\u3063\u3066\u3001\u4eca\u307e\u3067\u306e RSS \u30af\u30ed\u30fc\u30e9\u3092\u4fee\u6b63\u3002\u6b63\u76f4\u3082\u306e\u3059\u3054\u3044\u4fee\u6b63\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7,10,11,17],"tags":[],"class_list":["post-256","post","type-post","status-publish","format-standard","hentry","category-amazon-aws","category-html","category-linux","category-perl","category-17"],"_links":{"self":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/posts\/256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/comments?post=256"}],"version-history":[{"count":0,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/posts\/256\/revisions"}],"wp:attachment":[{"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/media?parent=256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/categories?post=256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pocolog.bass-world.net\/tech\/wp-json\/wp\/v2\/tags?post=256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}