Created
January 4, 2016 04:36
-
-
Save htfy96/df54e1fb5367c136b206 to your computer and use it in GitHub Desktop.
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
from __future__ import print_function | |
import urllib.request, urllib.parse | |
import sqlite3, zlib | |
import pathlib,os | |
db = sqlite3.connect('info.db') | |
cur = db.cursor() | |
cur.execute('select * from info where id>18000') | |
while True: | |
row = cur.fetchone() | |
try: | |
print(row[3]) | |
p = pathlib.Path( 'img'+urllib.parse.urlsplit(row[3]).path ) | |
try: | |
os.makedirs(str(p.parent)) | |
except FileExistsError as e: | |
print(e) | |
urllib.request.urlretrieve(row[3], str(p)) | |
except Exception as ee: | |
print(ee) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment