import requests
import json
def getAuthorHistory(author):
history = []
try:
author_url = f"https://j...content-available-to-author-only...k.com/api/article_users?author={author}"
author_response = requests.get(author_url)
author_data = author_response.json()
if 'data' in author_data and len(author_data['data']) > 0:
about_field = author_data['data'][0].get('about')
if about_field and about_field.strip():
history.append(about_field)
articles_base_url = f"https://j...content-available-to-author-only...k.com/api/articles?author={author}"
current_page = 1
total_pages = 1
while current_page <= total_pages:
articles_url = f"{articles_base_url}&page={current_page}"
articles_response = requests.get(articles_url)
articles_data = articles_response.json()
total_pages = articles_data.get('total_pages', 1)
if 'data' in articles_data:
for article in articles_data['data']:
title = None
if 'title' in article and article['title'] and article['title'].strip():
title = article['title']
elif 'story_title' in article and article['story_title'] and article['story_title'].strip():
title = article['story_title']
if title:
history.append(title)
current_page += 1
except Exception as e:
print(f"Error: {e}")
return history
print(getAuthorHistory('apaga'))