Skip to content
This repository has been archived by the owner on Jan 22, 2023. It is now read-only.

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
rly0nheart authored Jan 22, 2022
1 parent 3e21866 commit d08ae51
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,41 @@ def on_connection(self):
def search(self):
interval = 0
response = requests.get(self.api).json()
for number in range(interval, int(response['results']['per_page'])+1):
interval += 1
data = {"Company No#": response['results']['companies'][number]['company']['company_number'],
"Jurisdiction code": response['results']['companies'][number]['company']['jurisdiction_code'],
"Incorporation date": response['results']['companies'][number]['company']['incorporation_date'],
"Dissolution date": response['results']['companies'][number]['company']['dissolution_date'],
"Company type": response['results']['companies'][number]['company']['company_type'],
"Registry URI": response['results']['companies'][number]['company']['registry_url'],
"Branch": response['results']['companies'][number]['company']['branch'],
"Branch status": response['results']['companies'][number]['company']['branch_status'],
"Is inactive?": response['results']['companies'][number]['company']['inactive'],
"Current status": response['results']['companies'][number]['company']['current_status'],
"Created at": response['results']['companies'][number]['company']['created_at'],
"Updated at": response['results']['companies'][number]['company']['updated_at'],
"Previous name(s)": response['results']['companies'][number]['company']['previous_names'],
"Registered address": response['results']['companies'][number]['company']['registered_address'],
"Address in full": response['results']['companies'][number]['company']['registered_address_in_full'],
"Industry code(s)": response['results']['companies'][number]['company']['industry_codes'],
"Restricted for marketing": response['results']['companies'][number]['company']['restricted_for_marketing'],
"Native company No#": response['results']['companies'][number]['company']['native_company_number'],
"OpenCorporates URI": response['results']['companies'][number]['company']['opencorporates_url']
}
print(f"\n\n{white}{response['results']['companies'][number]['company']['name']}{reset}")
for key, value in data.items():
print(f"{white} ├─ {key}: {green}{value}{reset}")
if response['results']['companies'] == []:
print(f"{white}[{red}^{white}] No results found for {args.search}. Try a different search or try again later.{reset}")
else:
for number in range(interval, int(response['results']['per_page'])+1):
interval += 1
data = {"Company No#": response['results']['companies'][number]['company']['company_number'],
"Jurisdiction code": response['results']['companies'][number]['company']['jurisdiction_code'],
"Incorporation date": response['results']['companies'][number]['company']['incorporation_date'],
"Dissolution date": response['results']['companies'][number]['company']['dissolution_date'],
"Company type": response['results']['companies'][number]['company']['company_type'],
"Registry URI": response['results']['companies'][number]['company']['registry_url'],
"Branch": response['results']['companies'][number]['company']['branch'],
"Branch status": response['results']['companies'][number]['company']['branch_status'],
"Is inactive?": response['results']['companies'][number]['company']['inactive'],
"Current status": response['results']['companies'][number]['company']['current_status'],
"Created at": response['results']['companies'][number]['company']['created_at'],
"Updated at": response['results']['companies'][number]['company']['updated_at'],
"Previous name(s)": response['results']['companies'][number]['company']['previous_names'],
"Registered address": response['results']['companies'][number]['company']['registered_address'],
"Address in full": response['results']['companies'][number]['company']['registered_address_in_full'],
"Industry code(s)": response['results']['companies'][number]['company']['industry_codes'],
"Restricted for marketing": response['results']['companies'][number]['company']['restricted_for_marketing'],
"Native company No#": response['results']['companies'][number]['company']['native_company_number'],
"OpenCorporates URI": response['results']['companies'][number]['company']['opencorporates_url']
}
print(f"\n\n{white}{response['results']['companies'][number]['company']['name']}{reset}")
for key, value in data.items():
print(f"{white} ├─ {key}: {green}{value}{reset}")

if args.output:
print(self.write(data,number,response))

if number == int(response['results']['per_page'])-1:
break

if args.output:
print(self.write(data,number,response))

if number == int(response['results']['per_page'])-1:
break


# Writing results to a file
Expand Down

0 comments on commit d08ae51

Please sign in to comment.