importrequestsimportre# ConfigurationGITHUB_TOKEN='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'HEADERS={'Authorization':f'token {GITHUB_TOKEN}'}REGEX_PATTERN=re.compile(r'xai-[a-zA-Z0-9]{80}')OUTPUT_FILE='keys.txt'PAGES_TO_SCRAPE=5RESULTS_PER_PAGE=100defget_raw_content_url(html_url):"""Convert GitHub HTML URL to raw content URL."""returnhtml_url.replace('github.com','raw.githubusercontent.com').replace('/blob/','/')deffetch_keys():keys=set()forpageinrange(1,PAGES_TO_SCRAPE+1):# Search code for "xai-" on GitHubsearch_url=f'https://api.github.com/search/code?q="xai-"&per_page={RESULTS_PER_PAGE}&page={page}'response=requests.get(search_url,headers=HEADERS)ifresponse.status_code!=200:print(f"Failed to fetch page {page}: Status {response.status_code}")breakdata=response.json()foritemindata.get('items',[]):try:# Fetch raw contentraw_url=get_raw_content_url(item['html_url'])content_response=requests.get(raw_url)ifcontent_response.status_code==200:matches=REGEX_PATTERN.findall(content_response.text)forkeyinmatches:keys.add(key)exceptExceptionase:print(f"Error processing {item['html_url']}: {e}")returnkeysif__name__=="__main__":unique_keys=fetch_keys()withopen(OUTPUT_FILE,'w')asf:forkeyinunique_keys:f.write(f"{key}\n")print(f"Found {len(unique_keys)} keys and saved to {OUTPUT_FILE}")