| | import requests |
| | from googletrans import Translator |
| |
|
| | |
| | hf_token = "YOUR_HUGGING_FACE_TOKEN" |
| |
|
| | |
| | translator = Translator() |
| |
|
| | |
| | def fetch_popular_spaces(): |
| | headers = {"Authorization": f"Bearer {hf_token}"} |
| | response = requests.get("HUGGING_FACE_API_ENDPOINT", headers=headers) |
| | spaces_data = response.json() |
| | |
| | |
| | popular_spaces = spaces_data['spaces'][:20] |
| | |
| | translated_spaces = [] |
| | for space in popular_spaces: |
| | |
| | translated_desc = translator.translate(space['description'], dest='ko').text |
| | translated_spaces.append({ |
| | 'name': space['name'], |
| | 'description_ko': translated_desc |
| | }) |
| | |
| | return translated_spaces |
| |
|
| | |
| | if __name__ == "__main__": |
| | popular_spaces = fetch_popular_spaces() |
| | for space in popular_spaces: |
| | print(f"Space ์ด๋ฆ: {space['name']}, ์ค๋ช
: {space['description_ko']}") |