User:WikiProject Bot

First Code Snippet
import requests

api_url = 'https://en.wikipedia.org/w/api.php' character_limit = 5000 article_limit = 10

projects = [ {       'category': 'Category:Stub-Class Northern Ireland-related articles', 'project_reference': 'WikiProject Northern Ireland' },   {        'category': 'Category:Stub-Class Ireland articles', 'project_reference': 'WikiProject Ireland' } ]

def get_page_content(page_title): params = { 'action': 'parse', 'format': 'json', 'page': page_title, 'prop': 'wikitext', }   response = requests.get(api_url, params=params) data = response.json if 'error' in data: return None page_content = data['parse']['wikitext']['*'] return page_content

for project in projects: category = project['category'] project_reference = project['project_reference']
 * 1) Generate the result for each project

params = { 'action': 'query', 'format': 'json', 'list': 'categorymembers', 'cmtitle': category, 'cmtype': 'page', 'cmlimit': '500' # Increase the limit to retrieve more articles at once }

articles_list = [] article_count = 0 # Counter variable to track the number of articles found

while True: response = requests.get(api_url, params=params) data = response.json

for member in data['query']['categorymembers']: page_title = member['title'] is_talk_page = page_title.startswith('Talk:') article_title = page_title if not is_talk_page else page_title[5:] talk_page_title = f"Talk:{article_title}" article_page_content = get_page_content(article_title)

if article_page_content: article_page_length = len(article_page_content)

if article_page_length > character_limit: article_link = f"{article_title}" articles_list.append({                       'Article': article_link,                        'Character Count': article_page_length                    })

article_count += 1 if article_count == article_limit: break

if article_count == article_limit: break

if 'continue' in data: params.update(data['continue']) else: break

# Generate the result as Wikipedia text for the current project result = f"== Articles with Large Article Page Character Count related to {project_reference} ==\n\n" result += f"This is a list of articles from {project_reference} with a large article page character count.\n\n" result += f"For more information, visit the project page: {project_reference}\n\n" result += "List of articles:\n" if articles_list: for article in articles_list: result += f"* {article['Article']} (Character Count: {article['Character Count']})\n" else: result += "No articles found with a large article page character count.\n"

# Print the result for the current project print(result)