private static DataRow crawlRow(DataRow row, out bool isCompanyCrawled) { DataRow dr = row; isCompanyCrawled = false; try { //string t = "Grubstake, Llc"; //string searchQuery = "http://api.opencorporates.com/v0.4/companies/search?q=" + t.ToString().Replace(' ', '+'); string searchQuery = "http://api.opencorporates.com/v0.4/companies/search?q=" + dr[CompanyEnum.COMPANY_NAME].ToString().Replace(' ', '+'); string companyListString = HTTPUtility.getStringFromUrl(searchQuery); var jsonResponse = JsonConvert.DeserializeObject <JsonResponse>(companyListString); if (jsonResponse != null && jsonResponse.results.companies.Count > 0) { var selectedCompany = jsonResponse.results.companies.FirstOrDefault(c => c.company.inactive == false).company; if (selectedCompany != null) { int _delay = 2; int.TryParse(Delay, out _delay); _delay = _delay == 0 ? 2 * 1000 : _delay * 1000; Thread.Sleep(_delay); string coQuery = "http://api.opencorporates.com/v0.4/companies/" + selectedCompany.jurisdiction_code + "/" + selectedCompany.company_number; string companyResultString = HTTPUtility.getStringFromUrl(coQuery); Thread.Sleep(_delay); var companyResultResponse = JsonConvert.DeserializeObject <JsonResponseCompanyResult>(companyResultString); if (companyResultResponse != null) { var companyData = companyResultResponse.results.company; dr[CompanyEnum.OWNER_F_NAME] = getName(companyData.agent_name, true); dr[CompanyEnum.OWNER_l_NAME] = getName(companyData.agent_name, false); dr[CompanyEnum.OWNER_ADDR] = companyData.registered_address != null ? companyData.registered_address.street_address : companyData.registered_address_in_full; dr[CompanyEnum.OWNER_CITY] = companyData.registered_address?.locality ?? ""; int z = 0000; int.TryParse(companyData.registered_address?.postal_code, out z); dr[CompanyEnum.OWNER_STATE] = companyData.registered_address?.region ?? ""; dr[CompanyEnum.OWNER_ZIP] = z; string mailDescription = string.IsNullOrEmpty(getMailAddr(companyData)) ? companyData.registered_address_in_full ?? "" : ""; dr[CompanyEnum.MAIL_ADDR] = mailDescription; dr[CompanyEnum.MAIL_UNIT] = getMailUnits(mailDescription, 1); dr[CompanyEnum.MAIL_CITY] = getMailUnits(mailDescription, 2); dr[CompanyEnum.MAIL_STATE] = getMailUnits(mailDescription, 3); dr[CompanyEnum.MAIL_ZIP] = getMailUnits(mailDescription, 4); isCompanyCrawled = true; } } } } catch (Exception ex) { LoggerUtility.Write("Failed to crawl " + row["company name"].ToString(), ex.Message); isCompanyCrawled = false; } return(dr); }