<commit_before>import urllib
from pprint import pprint
import requests
import json

params = dict(API_TOKEN="61552c37f3ffd44bbe6a3473779895b3d3f2340b")

url = "https://api.github.com/search/repositories?q={}".format(input())


def main():
    # request = urllib.request.Request(url)
    # request.add_header('Authorization', 'token %s' % API_TOKEN)
    response = requests.get(url, params=params).text
    search_results = json.loads(response)
    download_url = search_results['items'][0]['html_url'] + '/archive/master.zip'
    print(download_url)
    urllib.request.urlretrieve(download_url, "{}.zip".format(search_results['items'][0]['name']))
    print("SAVED")

if __name__ == "__main__":<commit_msg>use environment variable for api token and refactor code<commit_after>from urllib.request import urlretrieve
import requests
import json
import os

params = dict(API_TOKEN=os.environ.get('GITHUB_API_TOKEN'))

url = "https://api.github.com/search/repositories?q={}".format(input())


def main():
    # request = urllib.request.Request(url)
    # request.add_header('Authorization', 'token %s' % API_TOKEN)
    response = requests.get(url, params=params).text
    search_results = json.loads(response)
    first_result = search_results['items'][0]
    download_url = first_result['html_url'] + '/archive/master.zip'
    print(download_url)
    urlretrieve(download_url, "{}.zip".format(first_result['name']))
    print("{}.zip saved in {}".format(first_result['name'], os.getcwd()))

if __name__ == "__main__":
{'fraction_non_alphanumeric': 0.154557463672391, 'fraction_numerical': 0.019815059445178335, 'mean_word_length': 5.530172413793103, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6280287', 'n_tokens_mistral': 513, 'n_tokens_neox': 510, 'n_words': 87}