-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.py
More file actions
35 lines (26 loc) · 1.2 KB
/
index.py
File metadata and controls
35 lines (26 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import json
# Replace the base URL with your actual API endpoint
base_url = "https://api.codenary.co.kr/techstack/list?page="
# Create an empty list to store all techstack names
all_techstack_names = []
# Loop through pages 1 to 21
for page_number in range(1, 22):
# Construct the complete URL for the current page
api_url = base_url + str(page_number)
# Make a request to the API
response = requests.get(api_url)
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Parse the JSON response
json_data = response.json()
# Extract the "name" from each "techstack"
techstack_names = [entry['techstack']['name'] for entry in json_data['techstacks']]
# Add the names to the overall list
all_techstack_names.extend(techstack_names)
else:
print(f"Failed to retrieve data for page {page_number}. Status code: {response.status_code}")
# Save the list of names to a JSON file
with open("techstack_names.json", "w", encoding="utf-8") as json_file:
json.dump(all_techstack_names, json_file, ensure_ascii=False, indent=2)
print("Techstack names have been saved to techstack_names.json")