Skip to content

Instantly share code, notes, and snippets.

@SS1031
Created December 3, 2013 07:03
Show Gist options
  • Save SS1031/7765111 to your computer and use it in GitHub Desktop.
Save SS1031/7765111 to your computer and use it in GitHub Desktop.
美人時計の1日分をダウンロードしてくるpythonスクリプト 20分くらいかかる。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, urllib
import os.path
import time
##############################################################################
# @brief 保存したいパスと画像のURLを渡すとローカルに保存する
# @param local_dir 保存先のパス ファイル名はURL最後の ooo.jpg となる
# @param url 保存したい画像のurl
##############################################################################
def download_img(local_dir, url):
img = urllib.urlopen(url)
file_name = "%s/%s" % (local_dir, os.path.basename(url))
localfile = open( file_name, 'wb')
localfile.write(img.read())
img.close()
localfile.close()
def get_allbijin():
# 24時間 60分 回す!
for i in range(0, 24):
for j in range(0, 60):
file_time = "%02d%02d" % (i, j)
url = "http://www.bijint.com/jp/tokei_images/%s.jpg" % (file_time)
download_img("./bijin", url)
# 0.5秒だけスリープしてやる 負荷をかけない優しさ
time.sleep(0.5)
##############################################################################
# @brief main
##############################################################################
def main():
target_dir = "./bijin"
if os.path.isdir(target_dir) == False:
os.makedirs(target_dir)
# 60 * 24 = 1440 人分の美人の画像を取ってくる
get_allbijin()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment