API 재업
# 클라이언트 초기화
from koneAPI import KoneClient
import json
import os
from typing import Dict, Any
def print_response(title: str, response) -> None:
"""API 응답을 출력하는 헬퍼 함수
Args:
title: 응답 제목
response: API 응답 객체
"""
print("\n" + "=" * 50)
print(f"[{title}] 상태 코드: {response.status_code}")
try:
json_data = response.json()
print(f"응답 데이터: {json.dumps(json_data, indent=2, ensure_ascii=False)}")
except:
print(f"응답 내용: {response.text[:200]}...") # 응답 내용 일부만 출력
print("=" * 50)
def main():
# 환경 변수에서 쿠키 값 가져오기 (보안을 위해)
# export KONE_COOKIE="여기에_실제_쿠키_값_입력" 명령으로 환경 변수 설정 가능
secure_neko_cookie = os.environ.get("KONE_COOKIE", "")
if not secure_neko_cookie:
print("오류: KONE_COOKIE 환경 변수가 설정되지 않았습니다.")
print("export KONE_COOKIE='쿠키값' 명령으로 환경 변수를 설정하세요.")
return
# 다른 서브를 사용하는 클라이언트 생성
kone_client = KoneClient(secure_neko_cookie, "kone")
print("\n\n=== 다른 서브 (kone) API 호출 예시 ===")
# 다른 서브의 배너 정보 가져오기
kone_banner_response = kone_client.api.get_sub_banner()
print_response("kone 서브 배너", kone_banner_response)
# 다른 서브의 운영자 목록 가져오기
kone_moderators_response = kone_client.api.get_sub_moderators()
print_response("kone 서브 운영자 목록", kone_moderators_response)
# 다른 서브의 웹 페이지 가져오기
kone_web_response = kone_client.web.get_sub_posts()
print(kone_web_response)
# 아티클 수정 테스트
kone_client.api.edit_sub_article("게시글 아이디", "제목", "<p>내용(HTML)</p>")
# 아티클 가져오기 테스트
kone_web_article_response = kone_client.web.get_article_info("게시글 아이디")
print(kone_web_article_response)
# 댓글 작성 테스트
# kone_client.api.post_comment("댓글 아이디", "테스트")
if __name__ == "__main__":
main()재업
2
5 comments
PY
7JWM652865SYIOuzte2YuO2ZlA==
wef4r2
04/21
1714
2
7JWM652865SYIOuzte2YuO2ZlA==
PY
wef4r2
04/21 1714 2
PY
동적 변수 import 질문
보성녹차드링커
11/29/25
1475
1
동적 변수 import 질문
PY
보성녹차드링커
11/29/25 1475 1
PY
서버의 디스크 공간을 사용하지 않는 신개?념 이미지 공유 api
fastapi
06/17/25
3224
-1
서버의 디스크 공간을 사용하지 않는 신개?념 이미지 공유 api
PY
fastapi
06/17/25 3224 -1
PY
파이썬 해보고 있는데 흥미롭네요
shashasha
05/30/25
3375
0
파이썬 해보고 있는데 흥미롭네요
PY
shashasha
05/30/25 3375 0
PY
API 재업
Ghost
05/17/25
4069
2
API 재업
PY
Ghost
05/17/25 4069 2
PY
Hello world
kartusias
05/17/25
3122
0
Hello world
PY
kartusias
05/17/25 3122 0
s/turtleneckers
• 1,620 subscribers프로그래밍 서브입니다. 잡담, 문제 해결, 코드 리뷰(공지 필독)
Created 05/17/2025, 14:30:39
Rules
- 1. 기본 방임주의(절대 귀찮아서 그런 것 맞음)
- 2. 누가봐도 밴 당할법한 글 올리면 자를꺼임
- 3. 카테고리 지켜주면 좋겠지만 안지키면 안타까운거고
Deleted comment.