import json from ImageRetriever import getImageforISBN ImgUrlJsonFile = open('./SP15/isbnData.json', 'r') ImgUrlData = json.load(ImgUrlJsonFile) filledJsonFile = open('./Results/filledisbnData.json', 'r') filledData = json.load(filledJsonFile) globalDict = {} print 'ImgUrlData: ', len(ImgUrlData) print 'filledData: ', len(filledData) counter = 0 for key, value in ImgUrlData.items(): if (key not in filledData): if ('title' not in value): imgDict = getImageforISBN(key) if (imgDict != 0): globalDict[key] = imgDict else: globalDict[key] = value counter += 1 print counter curr_dir = os.getcwd() curr_dir = curr_dir + '/Results' with open(curr_dir + '/diffisbnData.json', 'w') as ofile: json.dump(globalDict, ofile, sort_keys = True, indent = 4)
del tempDict['author'] if (len(tempDict) != 0): txtbook_info_dict['image_url'] = tempDict print 'ImgUrlData: ', ImgUrlData[ISBN] print 'isbnDict Update title: ', isbnDict print 'tempDict Update title: ', tempDict else: txtbook_info_dict['image_url'] = isbnDict isbnDict['title'] = txtbook_info_dict['title'] isbnDict['author'] = txtbook_info_dict['author'] ImgUrlData[ISBN] = isbnDict print 'isbnDict Update title: ', isbnDict else: #returns img dict of large/small images imgDict = getImageforISBN(ISBN) if (imgDict != 0): imgUrlDict ={} if (len(imgDict) != 0): txtbook_info_dict['image_url'] = imgDict imgUrlDict.update(imgDict) imgUrlDict['title'] = txtbook_info_dict['title'] imgUrlDict['author'] = txtbook_info_dict['author'] ImgUrlData[ISBN] = imgUrlDict else: #run again imgDict = getImageforISBN(ISBN) imgUrlDict ={}
import os import json from ImageRetriever import getImageforISBN ImgUrlJsonFile = open('./SP15/isbnData.json', 'r') ImgUrlData = json.load(ImgUrlJsonFile) filledJsonFile = open('./Results/filledisbnData.json', 'r') filledData = json.load(filledJsonFile) globalDict = {} print 'ImgUrlData: ', len(ImgUrlData) print 'filledData: ', len(filledData) counter = 0 for key, value in ImgUrlData.items(): if (key not in filledData): if ('title' not in value): imgDict = getImageforISBN(key) if (imgDict != 0): globalDict[key] = imgDict else: globalDict[key] = value counter += 1 print counter curr_dir = os.getcwd() curr_dir = curr_dir + '/Results' with open(curr_dir + '/diffisbnData.json', 'w') as ofile: json.dump(globalDict, ofile, sort_keys=True, indent=4)
if (len(tempDict) != 0): txtbook_info_dict['image_url'] = tempDict print 'ImgUrlData: ', ImgUrlData[ISBN] print 'isbnDict Update title: ', isbnDict print 'tempDict Update title: ', tempDict else: txtbook_info_dict['image_url'] = isbnDict isbnDict['title'] = txtbook_info_dict['title'] isbnDict['author'] = txtbook_info_dict[ 'author'] ImgUrlData[ISBN] = isbnDict print 'isbnDict Update title: ', isbnDict else: #returns img dict of large/small images imgDict = getImageforISBN(ISBN) if (imgDict != 0): imgUrlDict = {} if (len(imgDict) != 0): txtbook_info_dict['image_url'] = imgDict imgUrlDict.update(imgDict) imgUrlDict['title'] = txtbook_info_dict[ 'title'] imgUrlDict['author'] = txtbook_info_dict[ 'author'] ImgUrlData[ISBN] = imgUrlDict else: #run again imgDict = getImageforISBN(ISBN)