#!/usr/bin/env python3
"""Add harvin crawl config to daily_crawl_config.json"""
import json

config_path = '/root/gov_crawler/daily_crawl_config.json'

with open(config_path, 'r', encoding='utf-8') as f:
    config = json.load(f)

# Check if already exists
for c in config['crawlers']:
    if 'harvin' in c.get('script', ''):
        print(f"Already exists: {c['name']}")
        exit(0)

new_entry = {
    "name": "祥云股份-招标公告",
    "script": "crawl_harvin.py",
    "incremental": True,
    "args": "",
    "sync_mode": "direct_server",
    "enabled": True,
    "group": "企业",
    "note": "harvin.cn 祥云股份-招标公告, 中企动力(yun300.cn), AJAX列表(currentPage), 5页26条"
}

config['crawlers'].append(new_entry)

with open(config_path, 'w', encoding='utf-8') as f:
    json.dump(config, f, ensure_ascii=False, indent=2)

print(f"Added: {new_entry['name']}")
print(f"Total crawlers: {len(config['crawlers'])}")
