/// <summary> /// GetCrunchFinanceOrg retrieves the crunchbase info based on the permalink passed or null if not found. /// </summary> /// <param name="financeorg">permalink to a firm in the finance-organization namespace on crunchbase</param> /// <returns></returns> public CrunchFinancial GetCrunchFinanceOrg(string financeorg) { CrunchJsonStream cjStream = new CrunchJsonStream(); string jsonStream = cjStream.GetJsonStream(financeorg, "financial-organization"); if (jsonStream != null) { try { JavaScriptSerializer ser = new JavaScriptSerializer(); //with the stream, now deserialize into the Crunchbase object CrunchFinancial jsonCrunchBase = ser.Deserialize <CrunchFinancial>(jsonStream); Console.Error.WriteLine("Retrieved info for financial-organization {0}", jsonCrunchBase.name); return(jsonCrunchBase); } catch (Exception e) { Console.WriteLine("Oops, the exception {0} happened with {1}", e.ToString(), financeorg); return(null); } } else { return(null); } }
/// <summary> /// Gets the info about a company in Crunchbase /// </summary> /// <param name="crunchcompany">string that matches the shortname in crunchbase, for example as in companies collection name</param> /// <returns>Data in a CrunchBase class structure</returns> public CrunchBase GetCrunchCompany(string crunchcompany) { CrunchJsonStream cjStream = new CrunchJsonStream(); string jsonStream; jsonStream = cjStream.GetJsonStream(crunchcompany, "company"); if (jsonStream != null) { try { string jsonLine; JavaScriptSerializer ser = new JavaScriptSerializer(); //with the stream, now deserialize into the Crunchbase object CrunchBase jsonCrunchBase = ser.Deserialize <CrunchBase>(jsonStream); //assuming that worked, we need to clean up and create some additional meta data jsonCrunchBase.FixCrunchBaseURL(); jsonCrunchBase.AggregateFunding(); jsonCrunchBase.SplitTagString(); //and now we build the CSV string and write to file jsonLine = "\t" + jsonCrunchBase.GetImageURL() + "\t" + jsonCrunchBase.name + "\t" + jsonCrunchBase.homepage_url + "\t" + jsonCrunchBase.crunchbase_url + "\t" + jsonCrunchBase.description + "\t" + jsonCrunchBase.category_code + "\t" + jsonCrunchBase.number_of_employees + "\t" + jsonCrunchBase.hqcity + "\t" + jsonCrunchBase.hqstate + "\t" + jsonCrunchBase.hqcountry + "\t" + jsonCrunchBase.founded_year + "\t" + jsonCrunchBase.GetAggregateFunding().ToString() + "\t" + jsonCrunchBase.GetKeywordList(); /* + "\t\"" + //there are max of 5 keywords I will dump out * jsonCrunchBase.overview + "\"";*/ //I really wanted to put the "overview" field into the file, but the XLS import was //blowing up on the HTML...will need to revisit and fix // tw note: see http://www.blackbeltcoder.com/Articles/strings/convert-html-to-text jsonCrunchBase.tabdelimited = jsonLine; Console.Error.WriteLine("Retrieved info for {0}", jsonCrunchBase.name); return(jsonCrunchBase); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Oops, the exception {0} happened with {1}", e.ToString(), crunchcompany); return(null); } } else { return(null); } //if } //member get crunch