if line[0] != '-': pos_queries = pos_queries + [line[0:len(line)-1]] num_queries = num_queries + 1 if line[0] == '-': neg_queries = neg_queries + ' ' + line[0:len(line)-1] query_file.close() print('positive queries: ') print(pos_queries) print('negative queries: ' + neg_queries) print('num_queries = ' + str(num_queries)) #this is the desired number of photos in each block # make a new FlickrAPI instance fapi = FlickrAPI(flickrAPIKey, flickrSecret) for current_tag in range(0, num_queries): print('TOP OF LOOP') # change this to the location where you want to put your output file try: stats = os.stat(rootpath) except OSError: os.mkdir(rootpath) outpath = rootpath+pos_queries[current_tag]+'/' try: os.mkdir(outpath) except OSError: shutil.rmtree(outpath,True)
#!/usr/bin/env python import numpy as np import os, cv2, sys, string import math, time, socket, urllib from flickrapi2 import FlickrAPI from datetime import datetime import os.path as osp socket.setdefaulttimeout(30) FLICKR_PUBLIC = 'XX' FLICKR_SECRET = 'XX' fapi = FlickrAPI(FLICKR_PUBLIC, FLICKR_SECRET) def maybe_create(dir_path): if not osp.exists(dir_path): os.makedirs(dir_path) def get_urls(query_string, desired_num): extras = 'url_m' urls = [] try: rsp = fapi.photos_search(api_key=FLICKR_PUBLIC, ispublic="1", media="photos", license="2",