elif entity.cb_type == 'financial-organization' or entity.cb_type == 'service-provider': self.parseOffices(entity,data) # report self.stdout.write(entity.name.encode("utf8","ignore") + " updated\n") def getCBImage(self,entity,url): img_url = "http://www.crunchbase.com/" + url img_filename = urlparse(img_url).path.split('/')[-1] img = None try: img = urllib2.urlopen(img_url) except urllib2.HTTPError, e: self.stdout.write(str(e.code)) if img: logo = Image() logo.entity = entity logo.source = 'crunchbase' logo.type = 'logo' logo.save() with open('tmp_img','wb') as f: f.write(img.read()) with open('tmp_img','r') as f: img_file = File(f) logo.logo.save(img_filename,img_file,True) os.remove('tmp_img') self.stdout.write("Added image for " + entity.name.encode('utf8','ignore') + "\n") def getEntityCBInfo(self,entity): """ fetches full profile of entity from CB """ cb_url = self.getCBURL('info',entity.cb_type,entity=entity)
elif entity.cb_type == "financial-organization" or entity.cb_type == "service-provider": self.parse_offices(entity, data) # report sys.stdout.write(entity.name.encode("utf8", "ignore") + " updated\n") def get_cb_image(self, entity, url): img_url = "http://www.crunchbase.com/" + url img_filename = urlparse(img_url).path.split("/")[-1] img = None try: img = urllib2.urlopen(img_url) except urllib2.HTTPError, e: sys.stdout.write(str(e.code)) if img: logo = Image() logo.entity = entity logo.source = "crunchbase" logo.type = "logo" logo.save() with open("tmp_img", "wb") as f: f.write(img.read()) with open("tmp_img", "r") as f: img_file = File(f) logo.logo.save(img_filename, img_file, True) os.remove("tmp_img") sys.stdout.write("Added image for " + entity.name.encode("utf8", "ignore") + "\n") def get_entity_cb_info(self, entity): """ fetches full profile of entity from CB """ cb_url = self.get_cb_url("info", entity.cb_type, entity=entity)
# return industry object return industry def save_li_image(self,co,img_url): # self.stdout.write("Adding image for " + entity.name().encode('utf8','ignore') + "\n") # img_url = "http://www.crunchbase.com/" + url # img_filename = urlparse(img_url).path.split('/')[-1] img = None img_ext = urlparse.urlparse(img_url).path.split('/')[-1].split('.')[1] img_filename = co.name + "." + img_ext try: img = urllib2.urlopen(img_url) except urllib2.HTTPError, e: self.stdout.write(str(e.code)) if img: logo = Image() logo.entity = co logo.source = 'linkedin' logo.type = 'logo' logo.save() with open('tmp_img','wb') as f: f.write(img.read()) with open('tmp_img','r') as f: img_file = File(f) logo.logo.save(img_filename,img_file,True) os.remove('tmp_img') def add_office(self,co,office): o = Office() officeValues = {'description':'description','is-hq':'is-headquarters'}