diff --git a/clusters/intelligence-agencies.json b/clusters/intelligence-agencies.json index d34d3d1..fd7b254 100644 --- a/clusters/intelligence-agencies.json +++ b/clusters/intelligence-agencies.json @@ -1,5 +1,16 @@ { - "authors": "Wikipedia", + "authors": [ + "Graham87", + "Frietjes", + "Narky Blert", + "Pkbwcgs", + "Girth Summit", + "InternetArchiveBot", + "AnomieBOT", + "GreenMeansGo", + "MusikBot", + "Trappist the monk" + ], "category": "Intelligence Agencies", "description": "List of intelligence agencies", "name": "Intelligence Agencies", diff --git a/tools/IntelAgencies/main.py b/tools/IntelAgencies/main.py index 4e69bea..8f9c45a 100644 --- a/tools/IntelAgencies/main.py +++ b/tools/IntelAgencies/main.py @@ -155,6 +155,7 @@ if __name__ == '__main__': else: print(f'Error: {content}') + authors = [x['name'] for x in wiki.get_authors(page_title)] # Write to files galaxy = Galaxy( description="List of intelligence agencies", @@ -168,7 +169,7 @@ if __name__ == '__main__': galaxy.save_to_file(os.path.join(GALAXY_PATH, f'{GALAXY_NAME}.json')) cluster = Cluster( - authors="Wikipedia", + authors=authors, category="Intelligence Agencies", description="List of intelligence agencies", name="Intelligence Agencies", diff --git a/tools/IntelAgencies/modules/api.py b/tools/IntelAgencies/modules/api.py index b77b64c..05a772c 100644 --- a/tools/IntelAgencies/modules/api.py +++ b/tools/IntelAgencies/modules/api.py @@ -51,6 +51,22 @@ class WikipediaAPI(): response = requests.get(self.base_url, params=params) data = response.json() return data['parse']['text']['*'] + except Exception as e: + print(f'Error: {e}') + return None + + def get_authors(self, page_title): + params = { + 'action': 'query', + 'format': 'json', + 'titles': page_title, + 'prop': 'contributors', + } + try: + response = requests.get(self.base_url, params=params) + data = response.json() + page_id = next(iter(data['query']['pages'])) + return data['query']['pages'][page_id]['contributors'] except Exception as e: print(f'Error: {e}') return None \ No newline at end of file