chwrapper
chwrapper copied to clipboard
Multiple strings?
Hi,
Can we pass in multiple strings into the requests?
I tried the following:
def get_org_id():
org_id = {}
s = chwrapper.Search(access_token=config.api_key)
org_strings = ['001 INSPIRATION LIMITED', '007 PEST CONTROL LTD']
print(org_strings)
r = s.search_companies(list(org_strings))
print(r.text)
comp_house_dict = r.json()
# For each org_string in the sub-array of org_strings, pull org data from companies house
for word in org_strings:
for i in range(0, len(comp_house_dict['items']), 1):
org_title = str(comp_house_dict['items'][i]['title'])
basic_string_comph = org_title.replace(" ", " ")
basic_string_df = word.replace(" ", " ")
if basic_string_comph == basic_string_df:
print("MATCH")
org_id[word] = comp_house_dict['items'][i]['company_number']
org_id.update(org_id)
print(org_id)
return org_id
But only the first string in the list returns the dictionary I'm after {org_string : company_number} Thanks