import requests


credentials = 'your_zendesk_email', 'your_zendesk_password'
zendesk = 'https://your_subdomain.zendesk.com'
language = 'some_locale'
section_id = 123456

# Configure the list section articles endpoint
endpoint = zendesk + '/api/v2/help_center/{}/sections/{}/articles.json'.format(language, section_id)

while endpoint:             # keep going until the value is False
    response = requests.get(endpoint, auth=credentials)     # get a page of articles
    if response.status_code == 200:
        data = response.json()
    else:
        print('Failed to retrieve articles with error {}'.format(response.status_code))
        exit()

    for article in data['articles']:
        if article['comments_disabled']:   # if comments are already disabled, skip to the next article in the list
            continue
        update = {'article': {'comments_disabled': True}}
        url = zendesk + '/api/v2/help_center/{}/articles/{}.json'.format(language, article['id'])
        response = requests.put(url, json=update, auth=credentials)     # make the put request
        if response.status_code == 200:
            print('Comments disabled for article {}'.format(article['id']))
        else:
            print('{}: Error {}, {}'.format(article['id'], response.status_code, response.reason))

    endpoint = data['next_page']