대량 식당 메뉴 데이터 수집 실행기
CSV 파일에서 식당 목록을 로드하고, 지역별로 필터링하여 체계적으로 메뉴 정보를 수집하는 스크립트입니다.
- ✅ CSV 파일에서 식당 목록 로드 및 지역 필터링
- ✅ 수집 상태 관리 (success, failed, pending)
- ✅ 진행 상황 JSON 파일로 저장 및 추적
- ✅ 중단/재개 가능
- ✅ 실패한 항목만 선택적 재수집
- ✅ 주기적 자동 저장 (기본 10개마다)
python executor_collect_restaurant_menu.py \
--csv "식품_일반음식점.csv" \
--region "노원구"출력 파일: data/노원구_restaurants_progress_TIMESTAMP.json
python executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_20260215_123456.json"python executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_20260215_123456.json" \
--skip-failedpython executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_20260215_123456.json" \
--delay 3.0 \
--save-interval 5 \
--skip-failed| 옵션 | 설명 | 기본값 |
|---|---|---|
--csv |
식당 CSV 파일 경로 | 필수 |
--region |
필터링할 지역명 (예: "노원구") | 필수 |
--encoding |
CSV 파일 인코딩 | cp949 |
--output |
출력 파일 경로 | 자동 생성 |
| 옵션 | 설명 |
|---|---|
--resume |
재개할 진행 상황 JSON 파일 |
--skip-failed |
실패한 항목 스킵 (pending만 수집) |
| 옵션 | 설명 | 기본값 |
|---|---|---|
--delay |
요청 간 대기 시간 (초) | 2.0 |
--save-interval |
몇 개마다 저장할지 | 10 |
{
"metadata": {
"region": "노원구",
"created_at": "2026-02-15T10:00:00",
"last_updated": "2026-02-15T12:30:00",
"total": 500,
"pending": 100,
"success": 350,
"failed": 50,
"success_rate": "70.0%"
},
"restaurants": [
{
"unique_id": "abc123...",
"business_name": "푸른스시",
"business_status": "영업",
"road_address": "서울특별시 노원구 월계로 123",
"jibun_address": "서울특별시 노원구 월계동 123-45",
"query": "서울특별시 노원구 푸른스시",
"collection_status": "success",
"collection_attempts": 1,
"last_attempt_at": "2026-02-15T10:05:00",
"place_id": "1769424895",
"name": "푸른스시 광운대본점",
"category": ["일식", "초밥,롤"],
"address": "서울특별시 노원구 월계동 402-19",
"url": "https://map.naver.com/...",
"short_url": "https://naver.me/GYC6tGbl",
"short_hash": "GYC6tGbl",
"menus": [
{
"name": "오늘의초밥 11pcs",
"price": "13000",
"description": "",
"recommend": true,
"image_url": "https://..."
}
],
"error_message": null
}
]
}pending: 아직 수집 안 함success: 수집 성공failed: 수집 실패
CSV 로드 → 지역 필터링 → 진행 상황 파일 생성 → 순차 수집 → 주기적 저장
진행 상황 파일 로드 → 수집 대상 필터링 → 순차 수집 → 주기적 저장
python test_executor_collect_restaurant_menu.py테스트 내용:
- 고유 ID 생성 테스트
- CSV 로드 및 필터링 테스트
- 진행 상황 파일 생성/저장/로드 테스트
- 수집 상태 업데이트 시뮬레이션
- 재개 로직 시뮬레이션
DataCollection/
├── executor_collect_restaurant_menu.py # 메인 실행기
├── test_executor_collect_restaurant_menu.py # 테스트 스크립트
├── sample_restaurants.csv # 샘플 CSV
├── data/
│ └── *_restaurants_progress_*.json # 진행 상황 파일
└── test_data/ # 테스트 데이터 (자동 생성)
- 대용량 수집 시:
--delay값을 충분히 크게 설정 (3초 이상 권장) - 중단 시: Ctrl+C로 안전하게 중단 가능 (자동 저장)
- 재개 시: 항상 최신
*_progress.json파일 사용 - 실패 항목:
--skip-failed사용으로 시간 절약 가능
# 1단계: 전체 수집 시도
python executor_collect_restaurant_menu.py \
--csv "식품_일반음식점.csv" \
--region "노원구"
# 2단계: 실패/미수집 재시도
python executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_*.json"
# 3단계: 실패 제외하고 미수집만 재시도
python executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_*.json" \
--skip-failed--save-interval 20: 더 적게 저장 (더 빠름, 위험 증가)--save-interval 5: 더 자주 저장 (더 느림, 안전)--delay 1.0: 빠른 수집 (차단 위험)--delay 3.0: 안전한 수집 (느림)
collect_restaurant_menu_data.py: 단일 식당 수집 로직collect_area_menus.py: 기본 함수들run_area_collection.py: 지역별 대량 수집 (다른 방식)
# 새로운 수집
python executor_collect_restaurant_menu.py \
--csv "식품_일반음식점.csv" \
--region "노원구" \
--delay 2.5 \
--save-interval 10
# 중단 후 재개
python executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_20260215_100000.json"
# 실패 제외 재수집
python executor_collect_restaurant_menu.py \
--resume "data/노원구_restaurants_progress_20260215_100000.json" \
--skip-failed# 노원구
python executor_collect_restaurant_menu.py --csv "식품_일반음식점.csv" --region "노원구"
# 강남구
python executor_collect_restaurant_menu.py --csv "식품_일반음식점.csv" --region "강남구"
# 강동구
python executor_collect_restaurant_menu.py --csv "식품_일반음식점.csv" --region "강동구"--delay값 증가- 네트워크 연결 확인
- 진행 상황 파일 확인 (
error_message필드)
- 최신
*_progress.json파일 확인 - JSON 파일 손상 여부 확인
- 경로 확인
--save-interval값 감소 (더 자주 저장)- 지역을 더 세분화 (동 단위로)
만든 이: Claude Code + Anthropic 버전: 1.0.0 날짜: 2026-02-15