Skip to content

Instantly share code, notes, and snippets.

@htfy96
Created January 4, 2016 04:36
Show Gist options
  • Save htfy96/df54e1fb5367c136b206 to your computer and use it in GitHub Desktop.
Save htfy96/df54e1fb5367c136b206 to your computer and use it in GitHub Desktop.
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