diff --git a/skills/archived/atomk-auto-generate/SKILL.md b/skills/archived/atomk-auto-generate/SKILL.md new file mode 100644 index 0000000..034d93e --- /dev/null +++ b/skills/archived/atomk-auto-generate/SKILL.md @@ -0,0 +1,172 @@ +--- +name: atomk-auto-generate +description: Automatically log into AtomK, select a claimed product, choose an e-commerce platform, and AI-generate listing data. +--- +# AtomK Auto Generate Listing + +Automates logging into AtomK, opening a claimed product's editor, selecting a target platform (e.g., 速卖通, 亚马逊, Temu), and triggering AI generation. + +## Trigger +Use when user asks to: "一键生成", "生成速卖通资料", "生成亚马逊资料", or generate product info for a specific platform. + +## Prerequisites +- Node.js with Playwright installed at: `/home/ubuntu/.hermes/hermes-agent/node_modules/playwright` +- Playwright Chromium at: `/home/ubuntu/.cache/ms-playwright/chromium-1217/` + +## Critical Findings +- **Always use `https://www.atomlisting.com`** — `bt109atomk.sh3.ikuai7.com` silently fails on login (stays on /login). Both serve the same "九个网AtomK" app. +- **Direct editor URLs work best**: `/editor/{product_id}` allows bypassing the "My Products" scrolling/indexing problem entirely. +- **Generation status detection**: Check body text for "已生成" AND absence of "选择图片并点击" to confirm a listing already exists. "已生成" alone may appear in the AI generate button text. +- **DrissionPage works**: Use DrissionPage (installed in venv) rather than Playwright for consistency with other automation scripts. +- Login form uses standard inputs; press Enter on password field to submit. +- AtomK is a Next.js app (uses turbopack chunks, `_rsc` server components) + +## Execution Steps +1. Kill hung browser instances: `killall -9 chrome chromium chrome-headless-shell 2>/dev/null` +2. Save the script to `/tmp/atomk_generate.py` +3. Execute via terminal: + ```bash + /home/ubuntu/.hermes/hermes-agent/venv/bin/python3 /tmp/atomk_generate.py [product_index] + ``` + - `platform_name`: e.g., "速卖通", "亚马逊", "Temu" + - `product_index`: defaults to 0 (first product in list) + - Set timeout to ~30s for generation. + +## Batch Generation (Recommended) +For generating listings for multiple products efficiently, use **direct editor URLs** instead of navigating via the "My Products" page: + +```python +from DrissionPage import ChromiumPage, ChromiumOptions +import random, time + +TARGET_IDS = [607, 606, 605, 604] # product IDs to generate +PLATFORM = "Temu" + +def generate_for_product(page, product_id): + page.get(f'https://www.atomlisting.com/editor/{product_id}') + time.sleep(4) + + # Check if already generated + body_text = page.ele('tag:body').text + if '已生成' in body_text and '选择图片并点击' not in body_text: + print(f"ID={product_id}: already generated, skipping") + return True + + # Select platform + platform_btn = page.ele(f'text:{PLATFORM}') + if platform_btn: + platform_btn.click() + time.sleep(1) + + # Find and click generate button + for btn in page.eles('tag:button'): + if '生成' in btn.text: + btn.click() + print(f"ID={product_id}: generating...") + break + + # Poll for completion (up to 20s) + for i in range(20): + time.sleep(1) + body = page.ele('tag:body').text + if '已生成' in body or '标题' in body: + print(f"ID={product_id}: success!") + return True + return False +``` + +**Why direct URLs are better:** +- My Products page requires scrolling to load all products +- Edit button index mapping is unreliable (page may show 100+ products) +- Direct `/editor/{id}` is O(1) vs O(n) scrolling + +## Python Script (`/tmp/atomk_generate.py`) +```python +import sys +import time +from DrissionPage import ChromiumPage, ChromiumOptions + +def batch_generate(username, password, platform_name, product_ids): + """Generate AI listings for multiple products by ID.""" + co = ChromiumOptions() + co.set_browser_path('/home/ubuntu/.cache/ms-playwright/chromium-1217/chrome-linux64/chrome') + co.headless(True) + co.set_argument('--headless=new') + co.set_argument('--no-sandbox') + co.set_argument('--disable-dev-shm-usage') + co.set_argument('--disable-gpu') + co.set_argument('--window-size=1440,900') + co.set_user_agent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36') + co.set_local_port(0) + co.set_user_data_path(f'/tmp/dpcache_{int(time.time())}') + page = ChromiumPage(addr_or_opts=co) + + try: + print("Logging in...") + page.get('https://www.atomlisting.com') + time.sleep(2) + page.ele('css:input[placeholder="请输入用户名"]').input(username) + page.ele('css:input[placeholder="请输入密码"]').input(password) + page.ele('css:input[placeholder="请输入密码"]').input('\n') # press Enter to submit + time.sleep(5) + + success = 0 + for pid in product_ids: + print(f"\nProcessing product {pid}...") + page.get(f'https://www.atomlisting.com/editor/{pid}') + time.sleep(4) + + body_text = page.ele('tag:body').text + if '已生成' in body_text and '选择图片并点击' not in body_text: + print(f" Already generated, skipping.") + success += 1 + continue + + # Select platform + platform_btn = page.ele(f'text:{platform_name}') + if platform_btn: + platform_btn.click() + time.sleep(1) + + # Click generate button + gen_btn = None + for b in page.eles('tag:button'): + if '生成' in b.text: + gen_btn = b + break + + if gen_btn: + print(f" Clicking: {gen_btn.text}") + gen_btn.click() + + # Poll for completion + for i in range(20): + time.sleep(1) + body = page.ele('tag:body').text + if '已生成' in body or '标题' in body: + print(f" Generation successful!") + success += 1 + break + else: + print(f" Timed out, may still be processing.") + else: + print(" Generate button not found.") + + time.sleep(2) + + print(f"\nDone! {success}/{len(product_ids)} products processed.") + except Exception as e: + print("Fatal Error:", e) + finally: + page.quit() + +if __name__ == "__main__": + if len(sys.argv) < 5: + print("Usage: python3 atomk_generate.py [product_id2 ...]") + sys.exit(1) + user = sys.argv[1] + pwd = sys.argv[2] + plat = sys.argv[3] + ids = [int(x) for x in sys.argv[4:]] + batch_generate(user, pwd, plat, ids) +``` \ No newline at end of file