<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ひろぽっぽれす &#187; 美人時計</title>
	<atom:link href="http://hiropo.co.uk/archives/category/%e7%be%8e%e4%ba%ba%e6%99%82%e8%a8%88/feed" rel="self" type="application/rss+xml" />
	<link>http://hiropo.co.uk</link>
	<description>Web系エンジニアの適当なブログです。どうでも酔いものばかり作ってます。</description>
	<lastBuildDate>Mon, 12 Mar 2012 06:10:01 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>美人時計のカワイイ子をまとめた動画をつくってみた</title>
		<link>http://hiropo.co.uk/archives/437</link>
		<comments>http://hiropo.co.uk/archives/437#comments</comments>
		<pubDate>Sat, 03 Apr 2010 18:14:03 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=437</guid>
		<description><![CDATA[こんにちは。美人時計ネタです。 youtubeやニコ動でもよく見るのですが、動画編集をやってみたくて、美人時計のカワイイ子をまとめた動画をつくってみました。 ムービーメーカーむちゃくちゃ凄いです！ ※美人時計様、ご本人様 &#8230; <a href="http://hiropo.co.uk/archives/437">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>こんにちは。美人時計ネタです。<br />
youtubeやニコ動でもよく見るのですが、動画編集をやってみたくて、美人時計のカワイイ子をまとめた動画をつくってみました。</p>
<p>ムービーメーカーむちゃくちゃ凄いです！</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/YF2jihCUPRQ&#038;hl=ja_JP&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/YF2jihCUPRQ&#038;hl=ja_JP&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>※美人時計様、ご本人様からの削除要請がありましたら削除します。</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/437/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rubyでtwitterに投稿できるrubygems</title>
		<link>http://hiropo.co.uk/archives/429</link>
		<comments>http://hiropo.co.uk/archives/429#comments</comments>
		<pubDate>Sat, 13 Mar 2010 18:02:19 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=429</guid>
		<description><![CDATA[美人時計の画像を毎日収集してる僕です、こんばんみ！ ▽関連記事 美人時計の全画像を取得するスクリプトをバッチ化してみた 毎日美人時計とGAL時計と美人時計（北海道版）の画像をウチのサーバちゃんが収集して差分まで比較して結 &#8230; <a href="http://hiropo.co.uk/archives/429">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>美人時計の画像を毎日収集してる僕です、こんばんみ！</p>
<p>▽関連記事<br />
<a href="http://hiropo.co.uk/archives/331">美人時計の全画像を取得するスクリプトをバッチ化してみた</a></p>
<p>毎日美人時計とGAL時計と美人時計（北海道版）の画像をウチのサーバちゃんが収集して差分まで比較して結果だけ教えてくれています。<br />
収集Bot、かわいいよ、収集Bot。</p>
<p>そんな美人時計の差分が出たってのをtwitter経由で知らせてくれたらいいのに…と思いながら実装してみました。<br />
がしかし…、twitterには140文字という投稿制限があるんですね、見事140文字オーバーしたら投稿できませんでしたよ。</p>
<p>とりあえず、Rubyでtwitterに投稿できるrubygemsのインストールの仕方です。</p>
<pre>
rdocのインストール
# yum install rdoc

rubygemsのダウンロード
#wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz

rubygemsを解凍してインストール
# tar xvfz rubygems-1.3.5.tgz
# cd rubygems-1.3.5
# ruby setup.rb

gemでtwitterをインストール
% sudo gem install twitter
Successfully installed twitter-0.8.4
1 gem installed
Installing ri documentation for twitter-0.8.4...
Installing RDoc documentation for twitter-0.8.4...
</pre>
<p>こんな感じでサーバーにインストール。そしてRubyの書き方は下記の通り。</p>
<pre>
#------------------------------------------------------------
# ./twit.rb
def twit( v )
	#------------------------------------------------------------
	# twitter gems をインポート
	require 'rubygems'
	require 'twitter'

	#------------------------------------------------------------
	# Rubyから投稿
	twit_username = 'アカウント名'
	twit_password = 'ログインパスワード'

	auth = Twitter::HTTPAuth.new( twit_username, twit_password )
	twit = Twitter::Base.new( auth )
	twit.update( v )
	p 'twit!!'

	#------------------------------------------------------------
end

twit( 'てすつ投稿やねん' )
</pre>
<p>コマンドラインでプログラムを実行する。</p>
<pre>
host~% ruby ./twit.rb
</pre>
<p>これでRubyからtwitterに投稿できちゃう！Ruby、簡単だよ、Ruby。</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/429/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>美人時計のデジタルフォトフレーム版を作ってみた。 &#8211; DPF-D72N</title>
		<link>http://hiropo.co.uk/archives/425</link>
		<comments>http://hiropo.co.uk/archives/425#comments</comments>
		<pubDate>Mon, 01 Mar 2010 16:46:37 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[hack]]></category>
		<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=425</guid>
		<description><![CDATA[デジタルフォトフレームに美人時計をいれてみた。 スライドショーで、1分置きに画像を切り替えるようにしてみたので、スタートを現在の時間にすることによって、美人時計のデジタルフォトフレーム版が完成！もちろん1440枚全部入っ &#8230; <a href="http://hiropo.co.uk/archives/425">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>デジタルフォトフレームに美人時計をいれてみた。</p>
<p><a href="http://hiropo.co.uk/wp-content/uploads/2010/03/IMG_3448.jpg"><img src="http://hiropo.co.uk/wp-content/uploads/2010/03/IMG_3448.jpg" alt="" title="IMG_3448" width="640" height="426" class="alignnone size-full wp-image-426" /></a></p>
<p>スライドショーで、1分置きに画像を切り替えるようにしてみたので、スタートを現在の時間にすることによって、美人時計のデジタルフォトフレーム版が完成！もちろん1440枚全部入ってますよ！</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/q2llpaxMDbY&#038;hl=ja_JP&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/q2llpaxMDbY&#038;hl=ja_JP&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>我ながらよくやるわと思った。</p>
<p><iframe src="http://rcm-jp.amazon.co.jp/e/cm?lt1=_blank&#038;bc1=FFFFFF&#038;IS2=1&#038;npa=1&#038;bg1=FFFFFF&#038;fc1=000000&#038;lc1=0000FF&#038;t=funnythingz-22&#038;o=9&#038;p=8&#038;l=as1&#038;m=amazon&#038;f=ifr&#038;asins=B002TO4N3K" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/425/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>【美人時計】ニコニコ踊り娘 &#8211; ミンカ、Ire、いとくとら、まころん、馬琴</title>
		<link>http://hiropo.co.uk/archives/367</link>
		<comments>http://hiropo.co.uk/archives/367#comments</comments>
		<pubDate>Sat, 30 Jan 2010 17:05:56 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=367</guid>
		<description><![CDATA[ウチのサーバちゃんが相変わらず今もなお毎日美人時計の画像を収集している。今ではGAL時計も毎日収集していて、相変わらず差分のみちゃっかり保存しちゃってます。キモイね！ そんな美人時計の登場人物の差分をみていたんですけど、 &#8230; <a href="http://hiropo.co.uk/archives/367">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>ウチのサーバちゃんが相変わらず今もなお毎日美人時計の画像を収集している。今ではGAL時計も毎日収集していて、相変わらず差分のみちゃっかり保存しちゃってます。キモイね！</p>
<p>そんな美人時計の登場人物の差分をみていたんですけど、去年くらいまでは女の子が純粋に更新されいたっぽいんですが、最近はドラマや企業や企画モノなどとコラボして、画像が更新されている傾向にありますね。</p>
<p>そんなところでまずはニコニコ動画で有名（？）な踊り子とのコラボを紹介します。</p>
<p>上の列から、ミンカ、Ire、いとくとら、まころん、馬琴。<br />

<a href='http://hiropo.co.uk/archives/367/attachment/2008' title='2008'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20081-150x150.jpg" class="attachment-thumbnail" alt="2008" title="2008" /></a>
<a href='http://hiropo.co.uk/archives/367/2009-2' title='2009'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20092-150x150.jpg" class="attachment-thumbnail" alt="2009" title="2009" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2010' title='2010'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20101-150x150.jpg" class="attachment-thumbnail" alt="2010" title="2010" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2011' title='2011'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20111-150x150.jpg" class="attachment-thumbnail" alt="2011" title="2011" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2020' title='2020'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20201-150x150.jpg" class="attachment-thumbnail" alt="2020" title="2020" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2021' title='2021'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20211-150x150.jpg" class="attachment-thumbnail" alt="2021" title="2021" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2022' title='2022'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20221-150x150.jpg" class="attachment-thumbnail" alt="2022" title="2022" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2023' title='2023'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20231-150x150.jpg" class="attachment-thumbnail" alt="2023" title="2023" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2004' title='2004'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20042-150x150.jpg" class="attachment-thumbnail" alt="2004" title="2004" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2005' title='2005'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20051-150x150.jpg" class="attachment-thumbnail" alt="2005" title="2005" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2006' title='2006'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20061-150x150.jpg" class="attachment-thumbnail" alt="2006" title="2006" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2007' title='2007'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20072-150x150.jpg" class="attachment-thumbnail" alt="2007" title="2007" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2040' title='2040'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20401-150x150.jpg" class="attachment-thumbnail" alt="2040" title="2040" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2041' title='2041'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20411-150x150.jpg" class="attachment-thumbnail" alt="2041" title="2041" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2042' title='2042'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20421-150x150.jpg" class="attachment-thumbnail" alt="2042" title="2042" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2043' title='2043'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20431-150x150.jpg" class="attachment-thumbnail" alt="2043" title="2043" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2016' title='2016'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20161-150x150.jpg" class="attachment-thumbnail" alt="2016" title="2016" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2017' title='2017'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20171-150x150.jpg" class="attachment-thumbnail" alt="2017" title="2017" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2018' title='2018'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20181-150x150.jpg" class="attachment-thumbnail" alt="2018" title="2018" /></a>
<a href='http://hiropo.co.uk/archives/367/attachment/2019' title='2019'><img width="150" height="150" src="http://hiropo.co.uk/wp-content/uploads/2010/01/20191-150x150.jpg" class="attachment-thumbnail" alt="2019" title="2019" /></a>
</p>
<p>うん、みんな可愛いすぎるすな！</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/367/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>美人時計で画像を収集する際に使った計算式</title>
		<link>http://hiropo.co.uk/archives/360</link>
		<comments>http://hiropo.co.uk/archives/360#comments</comments>
		<pubDate>Wed, 27 Jan 2010 09:31:48 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=360</guid>
		<description><![CDATA[美人時計の画像を収集する際に、時間で画像名が吐き出されているので、その吐き出しの計算式をおこしてみた。 画像収集バッチはRubyなんですが、今回ちょっとJavaScriptを使う機会があったので、JavaScriptで起 &#8230; <a href="http://hiropo.co.uk/archives/360">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>美人時計の画像を収集する際に、時間で画像名が吐き出されているので、その吐き出しの計算式をおこしてみた。<br />
画像収集バッチはRubyなんですが、今回ちょっとJavaScriptを使う機会があったので、JavaScriptで起こしてみました。</p>
<pre>
&lt;div id=&quot;debug&quot;&gt;&lt;/div&gt;
</pre>
<pre>
(function(){
  var getid = function(id){
    return document.getElementById(id);
  }
  var debug = getid( &#039;debug&#039; );
  var dateCount = function(arg){
    return arg;
  }
  for( var i = 0; i &lt; 24; i++ ){
    for( var j = 0; j &lt; 60; j++ ){
      if( i &lt; 10 ){
        if( j &lt; 10 ){
          debug.innerHTML += &#039;0&#039; + i.toString() + &#039;0&#039; + j.toString() + &#039;.jpg&#039; + &#039;&lt;br /&gt;&#039;;
        }
        else{
          debug.innerHTML += &#039;0&#039; + i.toString() + j.toString() + &#039;.jpg&#039; + &#039;&lt;br /&gt;&#039;;
        }
      }
      else{
        if( j &lt; 10 ){
          debug.innerHTML += i.toString() + &#039;0&#039; + j.toString() + &#039;.jpg&#039; + &#039;&lt;br /&gt;&#039;;
        }
        else{
          debug.innerHTML += i.toString() + j.toString() + &#039;.jpg&#039; + &#039;&lt;br /&gt;&#039;;
        }
      }
    }
  }
})();
</pre>
<p>0000.jpg<br />
0001.jpg<br />
～略～<br />
2358.jpg<br />
2359.jpg</p>
<p>まで表示されます。</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/360/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>美人時計のGAL時計に若槻千夏が登場してた。</title>
		<link>http://hiropo.co.uk/archives/348</link>
		<comments>http://hiropo.co.uk/archives/348#comments</comments>
		<pubDate>Sun, 03 Jan 2010 16:27:03 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=348</guid>
		<description><![CDATA[あけおめです！今年もがしがし開発していくんでよろしくです。（なにを？） 前回書いた美人時計の画像取得スクリプトのCron化、GAL時計もはじめてみました。 ▽GAL時計 http://www.bijint.com/ 毎日 &#8230; <a href="http://hiropo.co.uk/archives/348">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>あけおめです！今年もがしがし開発していくんでよろしくです。（なにを？）<br />
前回書いた美人時計の画像取得スクリプトのCron化、GAL時計もはじめてみました。</p>
<p>▽GAL時計<br />
<a href="http://www.bijint.com/" target="_blank">http://www.bijint.com/</a></p>
<p>毎日0時にGAL時計の画像を収集し、2時に美人時計の画像を収集します。収集したからといって特に見ることなくツールつくっただけで満足しちゃってます。<br />
ただ毎日画像を収集していると、1日あたり400MB近く画像がたまっていくので、差分だけをHDDに残すようにしようと思い、比較差分のツールもつくりました。<br />
ただ単にマスターと今日落とした分のmd5を比較して、差分を別フォルダに保存するだけです。</p>
<pre>
#------------------------------------------------------------
#  ライブラリのインポート
#
require 'digest/md5'
require './ooiwa_frame_work'

$scriptPath = './gal_tokei/'
$targetDir = getTimeNow(0) + '_gal'
$todayDir = $scriptPath + $targetDir

#------------------------------------------------------------
#  前日と当日を比較するための関数
#
def hikaku( before, after )
	#------------------------------------------------------------
	#  前日の画像フォルダと、当日の画像フォルダから、
	#  画像リストを配列に代入
	#
	beforeList = Dir::entries( before ).to_s.gsub('...'){''}.gsub( /g([0-9])/ ){ 'g ' + $1 }.split(' ').sort()

	diffList = []

	beforeList.each do |val|
		rb = Digest::MD5.hexdigest( File.open( before + val, 'rb' ).read )
		ra = Digest::MD5.hexdigest( File.open( after + val, 'rb' ).read )

		if rb === ra
			# 処理なし
		else
			FileUtils.cp( after + val, $todayDir + '_diff/' + val )
			diffList.push( val )
		end
	end
	# 差分リストの書き出し
	if put_list( diffList, $scriptPath + 'log/' + $targetDir + '_list.txt' )
		print 'GAL時計の差分ファイルログを"' + $targetDir + '_list.txt"' + 'に書き出しました。'
		print "\n"
		return true;
	end
end
</pre>
<p>上記のスクリプトはサンプルです。実際には、上記スクリプトのhikakuメソッドを使用して、差分のみを当日フォルダに保存するといった処理をかましています。<br />
ちなみに &#8220;ooiwa_frame_work&#8221; という謎の自作ライブラリをかましてるので、コピペだけじゃ動かないかも。（意味なし。）</p>
<p>オマケに若槻千夏の画像でも。</p>
<p>0：00<br />
<img src="http://hiropo.co.uk/wp-content/uploads/2010/01/0000-300x228.jpg" alt="0000" title="0000" width="300" height="228" class="alignnone size-medium wp-image-349" /></p>
<p>18：00<br />
<img src="http://hiropo.co.uk/wp-content/uploads/2010/01/1800-300x228.jpg" alt="1800" title="1800" width="300" height="228" class="alignnone size-medium wp-image-350" /></p>
<p>この美人時計とかGAL時計、けっこうコラボしてるんだよねー。美人時計に出てる娘とかも、ニコニコ動画で有名な踊ってる娘がいたりとか、けっこう収集してて面白いよね。</p>
<p>何か最近、こずえちゃんとミンカちゃんとかとユニットを組んだらしい「いといくら」こといくらちゃん。<br />
可愛過ぎるわ。<br />
<script type="text/javascript" src="http://ext.nicovideo.jp/thumb_watch/sm4146159"></script><noscript><a href="http://www.nicovideo.jp/watch/sm4146159">【ニコニコ動画】キラッ☆星間飛行を踊ってみた＠いとくとら</a></noscript></p>
<p>いくらちゃんの美人時計<br />
<img src="http://hiropo.co.uk/wp-content/uploads/2010/01/2004-300x228.jpg" alt="2004" title="2004" width="300" height="228" class="alignnone size-medium wp-image-351" /><br />
<img src="http://hiropo.co.uk/wp-content/uploads/2010/01/2007-300x228.jpg" alt="2007" title="2007" width="300" height="228" class="alignnone size-medium wp-image-352" /></p>
<p>むっちゃくちゃ可愛いですお（＾ｑ＾）オレの方が可愛いけどなっ！</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/348/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>美人時計の全画像を取得するスクリプトをバッチ化してみた</title>
		<link>http://hiropo.co.uk/archives/331</link>
		<comments>http://hiropo.co.uk/archives/331#comments</comments>
		<pubDate>Fri, 20 Nov 2009 02:18:23 +0000</pubDate>
		<dc:creator>hirohi</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[美人時計]]></category>

		<guid isPermaLink="false">http://hiropo.co.uk/?p=331</guid>
		<description><![CDATA[最近流行り（？）の美人時計。Web業界の人間ならだいたいの人は知っているんじゃないでしょうかね。1分置きに女の子が変わるというこのサービス。女の子が変わるまでずーっと24時間も待っていられないので、全画像を取得するスクリ &#8230; <a href="http://hiropo.co.uk/archives/331">続きを読む <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>最近流行り（？）の<a href="http://www.bijint.com/jp/" target="_blank">美人時計</a>。Web業界の人間ならだいたいの人は知っているんじゃないでしょうかね。1分置きに女の子が変わるというこのサービス。女の子が変わるまでずーっと24時間も待っていられないので、全画像を取得するスクリプトをつくってしまいたくなりました。</p>
<p>とりあえず誰かすでにつくってるんじゃないだろうかと思い、google先生にきいてみました。</p>
<p>案の定すぐみつかりましたよ！素敵スクリプトをつくっている方が！</p>
<p>▽こちら<br />
『<a href="http://d.hatena.ne.jp/Yamashiro0217/20090930/1254305886" target="_blank">Yamashiro0217の日記</a>』</p>
<p>Rubyで組まれているようです。僕はPHP派なので、Rubyまったくわかりませんが、この際Rubyに入門してしまおう！ってことで、Yamashiro0217さんのスクリプトを参考にスクリプトをつくってみようと思います。</p>
<p>まずはRubyスクリプトの動作確認<br />
Yamashiro0217さんのスクリプトをコピペで動かしてみます。</p>
<p>▽開発環境<br />
Fedora10のインストールされたLinuxサーバ。<br />
Rubyはすでにインストール済み。</p>
<p>▽美人時計の全画像取得スクリプト<br />
bijin.ruby</p>
<pre>
require 'net/http'
require 'uri'

error_files = ""
0..24.times do |hour|
   0..60.times do |minute|
      now_hour = sprintf("%0#{2}d", hour)
      now_minute = sprintf("%0#{2}d", minute)
      sleep 1
      begin
         Net::HTTP.start("bijint.com", 80) do |http|
         response = http.get(
         	"/jp/img/clk/#{now_hour}#{now_minute}.jpg",
         	{"Referer" => "http://bijint.com/jp/" }
         )
         open( "#{now_hour}#{now_minute}.jpg", "wb" ) do |file|
             file.puts response.body
         end
      end
      rescue
         p "#{now_hour}#{now_minute}.jpg can not get"
         error_files += "http://bijint.com/jp/img/clk/#{now_hour}#{now_minute}.jpg\n"
      end
   end
end
</pre>
<p>▽コマンドから実行</p>
<pre>
[ooiwa@eva bijin_tokei]$ ruby bijin.ruby
</pre>
<p>おぉー！画像がどんどん落ちてきたよー！これは感動！とりあえず動作確認はOKと。</p>
<p>ただこの美人時計、落とした画像ファイルと、本番サイトの美人時計側で女の子の表示が違うときがあります。どうやら日々ちょこちょこ女の子が更新されているようです。これはなんということ！全女の子コンプリートするには定期的にチェックするしかないじゃないか！ということで、この際毎日取得してしまうスクリプトを組んでみようと思います。</p>
<p>それではバッチをつくっていきます。<br />
定期的に1日毎に決まった時間に全画像を取得して、なおかつ日付ごとにディレクトリを分けて保存する、バッチをまわすのはCron、スクリプト言語はRubyをつかってつくっていきます。</p>
<p>まず、Yamashiro0217さんのスクリプトをこのまま使うと、スクリプトと同じパスに画像をそのままダウンロードしてきますので、日付毎にディレクトリを切ってくれる関数を用意します。<br />
今回はわかりやすいようにスクリプトを起動した日の日付を取得して&#8221;yyyymmdd&#8221;形式で文字列を返す関数と、ディレクトリを生成する関数を用意します。</p>
<p>▽今日の日付をyyyymmdd型の文字列に変換する関数</p>
<pre>
def getTimeNow()
    day = Time.now
    putMonth = day.month.to_s
    putDay = day.day.to_s

    if day.month < 10 &#038;&#038; day.day < 10
        putMonth = '0' + day.month.to_s
        putDay = '0' + day.day.to_s
    elsif day.month < 10
        putMonth = '0' + day.month.to_s
    elsif day.day < 10
        putDay = '0' + day.day.to_s
    end

    nowTime = day.year.to_s + putMonth + putDay
    return nowTime
end
</pre>
<p>▽ディレクトリの生成</p>
<pre>
def mkdir(path)
    if Dir::mkdir( path, 0777 )
        return true
    else
        return false
    end
end
</pre>
<p>あとは、Yamashiro0217さんのスクリプトにディレクトリパスを突っ込んで、一通り完成させる。今回Cronでバッチ処理させるため、ディレクトリパスは絶対パスで書く。</p>
<p>▽スクリプトをまとめたのがこれ<br />
bijin.ruby</p>
<pre>
#――――――――――――――――――――――――――――――
#  美人時計の画像を全取得するスクリプト
#
#------------------------------------------------------------
#  ライブラリのインポート
#
require &#039;net/http&#039;
require &#039;uri&#039;

#------------------------------------------------------------
#  Global var
#
$scriptPath = &#039;bijin_tokei/&#039;

p $scriptPath

#------------------------------------------------------------
#  今日の日付をyyyymmdd型の文字列に変換する関数
#
def getTimeNow()
	day = Time.now
	putMonth = day.month.to_s
	putDay = day.day.to_s
	if day.month &lt;10 &amp;&amp; day.day &lt;10
		putMonth = &#039;0&#039; + day.month.to_s
		putDay = &#039;0&#039; + day.day.to_s
	elsif day.month &lt;10
		putMonth = &#039;0&#039; + day.month.to_s
	elsif day.day &lt;10
		putDay = &#039;0&#039; + day.day.to_s
	end
	nowTime = day.year.to_s + putMonth + putDay
	return nowTime
end

p getTimeNow()

#------------------------------------------------------------
#  ディレクトリの生成
#
def mkdir(path)
	if Dir::mkdir( path, 0777 )
		return true
	else
		return false
	end
end

#------------------------------------------------------------
#  美人時計から画像を取得
#
def getBijin()
	error_files = &quot;&quot;
	0..24.times do |hour|
	   0..60.times do |minute|
	      now_hour = sprintf(&quot;%0#{2}d&quot;, hour)
	      now_minute = sprintf(&quot;%0#{2}d&quot;, minute)
	      sleep 1
	      begin
	         Net::HTTP.start(&quot;bijint.com&quot;, 80) do |http|
	         response = http.get(&quot;/jp/img/clk/#{now_hour}#{now_minute}.jpg&quot;,
	                             {&quot;Referer&quot; =&gt; &quot;http://bijint.com/jp/&quot; })
	         open( $scriptPath + getTimeNow() + &quot;/#{now_hour}#{now_minute}.jpg&quot;, &quot;wb&quot; ) do |file|
	             file.puts response.body
	         end
	      end
	      rescue
	         p &quot;#{now_hour}#{now_minute}.jpg can not get&quot;
	         error_files += &quot;http://bijint.com/jp/img/clk/#{now_hour}#{now_minute}.jpg\n&quot;
	      end
	   end
	end
end

#------------------------------------------------------------
#  初期実行関数
#
def init()
	targetDir = $scriptPath + getTimeNow()
	if File.exists?( targetDir )
		getBijin()
	else
		if mkdir( targetDir )
			p &#039;make!&#039;
			getBijin()
		end
	end
end
init()
</pre>
<p>Rubyは変数の定義がグローバルとローカルでスコープがわかりやすいから良いですね！なんかPHPより全然カンタンだし、オブジェクト指向言語だし、個人的にはだいぶ気に入りました。</p>
<p>完成したスクリプトを早速実行してみます。</p>
<pre>
[ooiwa@eva bijin_tokei]$ ruby /home/ooiwa/tmp_ruby/bijin_tokei/bijin.ruby
[ooiwa@eva bijin_tokei]$ ls
20091120  bijin.ruby
[ooiwa@eva bijin_tokei]$ ls 20091120/
0000.jpg 0001.jpg 0002.jpg
</pre>
<p>うまく動いていれば、本日の日付ディレクトリが生成され、そのディレクトリの中に画像をどんどんたまっていっているのがわかります。</p>
<p>最後はこの完成したスクリプトをCronでまわす処理をします。</p>
<pre>
[ooiwa@eva bijin_tokei]$ crontab -e
#毎日10:00に bijin.ruby スクリプトを実行
0 10 * * * ruby /home/ooiwa/tmp_ruby/bijin_tokei/bijin.ruby
</pre>
<p>あとは毎日10時になるとCronがRubyスクリプトを実行してくれます。<br />
これであとは目視で比較するか、md5で比較するツールでもつくって差分を分けるスクリプトを足すかでもすればどの女の子が削除されて追加されたかがわかりますね。</p>
<p>美人時計、面白いです。</p>
]]></content:encoded>
			<wfw:commentRss>http://hiropo.co.uk/archives/331/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

