Add [cluster] authors

pull/946/head
niclas 2024-03-12 14:06:14 +01:00
parent 3ece11b87f
commit 04c07e4774
3 changed files with 30 additions and 2 deletions

View File

@ -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",

View File

@ -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",

View File

@ -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