Created
October 22, 2012 00:43
-
-
Save sakadonohito/3929110 to your computer and use it in GitHub Desktop.
特定のURL内の画像が数字の連番の場合の画像取得サンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding:utf-8 -*- | |
| import sys, urllib | |
| import os.path | |
| def download(url): | |
| img = urllib.urlopen(url) | |
| localfile = open( os.path.basename(url), 'wb') | |
| localfile.write(img.read()) | |
| img.close() | |
| localfile.close() | |
| if __name__ == '__main__': | |
| base_url = ''#ここに特定のパスをいれておく | |
| #rangeはお好みで | |
| for i in range(1,177): | |
| download(base_url+("000" + str(i))[-3:]+'.jpg') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment