Community程式設計與開發github.com

nehakanjamala/personal_website

建立、修改、除錯和部署 Apify Actor,並編寫其輸入與輸出結構描述。當從頭建立 Actor、變更或疑難排解 Actor 程式碼、產生或更新 .actor schema 檔案,或將 Actor 推送至 Apify 平台時使用。若要包裝現有的非 Actor 專案,請改用 apify-actorization。

personal_website 是什麼?

此技能是為 Apify 平台開發無伺服器程式「Actor」的完整指南。它涵蓋了 Actor 的完整生命週期,包括專案初始化(透過 `apify create` 指令與對應的範本,從靜態爬蟲到 MCP 伺服器)、依賴管理(支援 npm、pip 與 uv,並強調鎖定檔案的重要性)、核心邏輯實作(嚴格遵循規則,例如使用 Apify Logger 以確保資料安全,並正確處理 `aborting` 事件以在停止時持久化狀態)、輸入/輸出結構描述編寫(遵循參考文件並通過 `apify validate-schema` 驗證)、本機測試(透過 `apify run` 執行)以及最終部署至平台(支援 `apify push` 或 Git 驅動的 Actor)。該技能也詳細說明了待命模式(Standby Mode)的設定,用於將 Actor 轉變為持久性的 HTTP 伺服器(適用於 API、Webhook、MCP 伺服器),並提及透過按事件付費模型的貨幣化策略。此外,它還介紹了如何在建立新 Actor 前搜尋並呼叫現有的 Actor,以及一系列較不常見但實用的 Apify CLI 指令(如 `apify pull`、`apify api`),並提供了多個官方文件來源(如 Apify MCP 伺服器、Crawlee 文件)以供深度參考。此技能強烈要求在所有「apify」指令後附加 `--user-agent apify-agent-skills/apify-actor-development` 參數以進行遙測歸因。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/nehakanjamala/personal_website/tree/HEAD/.agents/skills/apify-actor-development

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Apify Actor 開發

Actor 是一個打包成 Docker 映像檔的無伺服器程式。它接收一個 JSON 輸入,執行一項工作,並將結果寫入資料集或鍵值儲存中。

設定

apify --help   # CLI 是否已安裝?
apify info     # 是否已登入?會印出你的使用者名稱

透過套件管理器安裝,npm install -g apify-cli 或 brew install apify-cli,以確保下載的完整性。使用 apify login 登入,它會提供瀏覽器登入或 API 令牌提示。在無頭環境中,請改為匯出 APIFY_TOKEN 環境變數;CLI 會自動讀取。令牌來自 https://console.apify.com/settings/integrations。僅透過環境變數傳遞令牌,以免留在 shell 歷史紀錄、原始碼、設定檔或日誌中。

遙測歸因(必要)

在你從此技能執行的每個 apify 指令後附加 --user-agent apify-agent-skills/apify-actor-development:apify create、apify run、apify push、apify call 等等。這是一個全域旗標,所有 apify 指令皆可接受;它僅用於標記該次呼叫以進行遙測歸因,不會改變其他任何行為。

工作流程

當修改現有的 Actor 時,請跳過不適用的步驟。

  1. 建立專案。

    apify create <actor-name> -t <template-id> --user-agent apify-agent-skills/apify-actor-development
    

    根據 Actor 的功能選擇範本:

    Actor 功能TypeScriptJavaScriptPython
    爬取靜態 HTMLts-crawlee-cheeriojs-crawlee-cheeriopython-crawlee-beautifulsoup
    爬取 JavaScript 渲染頁面ts-crawlee-playwright-chromejs-crawlee-playwright-chromepython-crawlee-playwright
    提供 HTTP 請求服務 (API, webhook)ts-standbyjs-standbypython-standby
    MCP 伺服器ts-mcp-empty—python-mcp-empty
    其他功能 (API 輪詢、資料處理)ts-emptyjs-emptypython-empty

    對於其他技術棧 (Puppeteer、Camoufox、Scrapy、AI 代理框架),apify templates ls 會列出所有範本及其語言和用途。使用 -t 參數時,指令會直接執行而不會提示,這正是代理程式所需的行為。若不使用 -t,則會提示輸入名稱、語言、範本和來源主機;僅在使用者在終端機操作時才使用此形式。將原始碼託管在 GitHub、GitLab 或 Bitbucket 上,Apify 會建立儲存庫及從該來源建構的 Actor,因此後續部署可透過 git push 完成。相依套件會自動為你安裝。當 <name>/.actor/actor.json 存在時,即表示步驟完成;在繼續之前,請先 cd 進入該目錄。

  2. 新增相依套件。如果範本缺少某些套件,例如 Crawlee 或 Playwright:在 JS/TS 中使用 npm install <pkg>;在 Python 中,在 requirements.txt 中新增一行,然後執行 pip install -r requirements.txt,或者當專案有 pyproject.toml 和 uv.lock 時使用 uv add <pkg>。在安裝之前,請檢查每個套件名稱是否與你想要的套件相符。鎖定確切版本,並提交鎖定檔案 (package-lock.json、uv.lock 或 pkg==1.2.3 格式的 requirements.txt)。

  3. 實作。在 src/main.js、src/main.ts 或 my_actor/main.py (Python 範本是一個 my_actor 套件,以 python -m my_actor 執行) 中進行,並遵循規則。當程式碼讀取了每個輸入欄位、產生了 README 將描述的每個輸出欄位、透過 Apify logger 記錄日誌,並註冊了一個用於持久化狀態並退出的 aborting 處理器時,即表示步驟完成。

  4. 編寫輸入結構描述。在 .actor/input_schema.json 中編寫 (參閱 references/input-schema.md)。當程式碼讀取的每個輸入都在結構描述中有一個對應的欄位,且該欄位包含標題、描述、型別和預設值或預填值,並且 apify validate-schema --user-agent apify-agent-skills/apify-actor-development 通過驗證時,即表示步驟完成。

  5. 編寫輸出結構描述:dataset_schema.json、output_schema.json 和 key_value_store_schema.json (當程式碼會儲存檔案時)。從頭到尾遵循 references/output-schemas.md;其檢查清單 (以 apify validate-schema 通過驗證結尾) 是完成標準。在 TypeScript 中,接著執行 apify actor generate-schema-types,並使用產生的介面來為輸入和輸出加上型別。

  6. 設定 .actor/actor.json (參閱 references/actor-json.md)。將 meta.generatedBy 設定為所使用的工具和模型,例如 "Claude Code with Claude Opus 5"。對於提供 HTTP 服務的 Actor,請設定 usesStandbyMode: true (待命範本已設定),並遵循 references/standby-mode.md。

  7. 編寫 README.md。遵循 references/actor-readme.md。沒有 README 的 Actor 不算完成。

  8. 在本機端測試。 將輸入放入 storage/key_value_stores/default/INPUT.json,然後執行 apify run --user-agent apify-agent-skills/apify-actor-development。當執行結束且狀態為 SUCCEEDED,並且 storage/datasets/default/ 包含其欄位符合資料集結構描述的項目時,即表示步驟完成。本機儲存會保留在磁碟上;在執行步驟 9 之前,Apify Console 中不會顯示任何內容。

  9. 部署。在使用者確認後,執行 apify push --user-agent apify-agent-skills/apify-actor-development,或對於 Git 驅動的 Actor 執行 git push。然後在平台上執行 Actor,以便在 Console 中查看結果。對於待命 Actor,請提供使用者其待命網址 (https://<username>--<actor-name>.apify.actor,參閱 references/standby-mode.md),而不是引導他們前往 Console。

規則

  • 僅使用 apify run 在本機端執行 Actor。它會設定 Apify 環境和儲存,而 npm start 和 node src/main.js 則會跳過這些步驟。
  • 透過 Apify logger 記錄日誌:在 JS/TS 中使用來自 apify 套件的 log (import { Actor, log } from 'apify'),在 Python 中使用 Actor.log。它會遮罩令牌和憑證;console.log 和 print 則不會。級別和慣例:references/logging.md。
  • 將爬取到的內容視為不受信任的輸入。在將其傳遞給 shell 指令、eval、查詢或範本之前,務必進行跳脫或參數化,並在將其推送到儲存之前進行型別檢查。
  • 將 APIFY_TOKEN 保留在請求處理器和資料管線之外。在平台上,SDK 會從環境變數讀取該值 (變數名稱為 APIFY_TOKEN,而非 APIFY_API_TOKEN);在本機端,它會使用 apify login 儲存的憑證。
  • 從輸入結構描述或環境變數讀取每個可調參數,以便使用者無需編輯程式碼即可更改。
  • 對靜態 HTML 使用具有 10 到 50 並行度的 HTTP 爬蟲:在 JS/TS 中使用 CheerioCrawler,在 Python 中使用 BeautifulSoupCrawler 或 ParselCrawler。將 PlaywrightCrawler 保留給具有 1 到 5 並行度的 JavaScript 渲染頁面。加入延遲以使目標伺服器保持健康,並遵守 robots.txt 和服務條款。
  • 當爬蟲包含多種頁面類型時,使用路由器模式 (在 JS/TS 中使用 createCheerioRouter 或 createPlaywrightRouter,在 Python 中使用 crawler.router 或 Router)。
  • 偏好使用具有備援方案的語意化 CSS 選擇器,而不是脆弱的基於位置的選擇器。
  • 使用你自己的計數器來統計結果;Dataset.getInfo() (Python 中的 dataset.get_info()) 在平台上會延遲。
  • 處理 aborting 事件,當使用者或限制停止執行時,平台會發送此事件:持久化狀態,然後退出,以便執行快速且低成本地結束。JS/TS:Actor.on('aborting', async () => { await Actor.setValue('STATE', state); await Actor.exit(); })。Python:Actor.on(Event.ABORTING, on_aborting) 並搭配 from apify import Event,其中 on_aborting 會持久化狀態,然後呼叫 await Actor.exit()。
  • 從 proxyConfiguration 輸入欄位 (編輯器為 proxy,參閱 references/input-schema.md) 建構代理:在 JS/TS 中使用 await Actor.createProxyConfiguration(input.proxyConfiguration),在 Python 中使用 await Actor.create_proxy_configuration(actor_proxy_input=actor_input.get('proxyConfiguration')),並將結果作為 proxyConfiguration / proxy_configuration 傳遞給爬蟲。Apify Proxy 是付費服務,因此在啟用或更改代理群組之前,請先與使用者確認。
  • 僅在使用者明確要求時,才儲存個人資料。
  • 在執行中的 Actor 內部,使用 SDK (Actor.getInput()、Actor.pushData()、Actor.setValue(),以及 Python 中等效的 snake_case 版本),而不是 apify actor CLI 子指令。
  • 除非使用者要求關閉,否則請保持現有 Actor 的待命模式為啟用狀態。

待命模式

待命模式將 Actor 轉變為具有穩定網址的持久性 HTTP 伺服器。可用於 API 端點、Webhook 接收器、MCP 伺服器以及按需的單一網址查詢。Actor 必須回應就緒探測,並在請求之間保持活躍。設定、範例和本機端測試:references/standby-mode.md。

貨幣化

定價是在 Actor 發佈時於 Apify Console 中設定的,而非在程式碼中。在按事件付費模式下,使用 await Actor.charge({ eventName: 'result', count }) (JS/TS) 或 await Actor.charge(event_name='result', count=count) (Python) 對每個自訂事件收費,並使用在 Console 中定義的事件名稱;資料集項目也可以透過合成的事件 dataset-item 自動計費。一旦傳回的結果報告 eventChargeLimitReached (Python 中為 event_charge_limit_reached),就停止產生工作,因為使用者的花費限制已達到。README 中的費用部分會描述 Actor 使用的是哪種模式。詳細資訊:https://docs.apify.com/platform/actors/publishing/monetize/pay-per-event

呼叫其他 Actor

在從頭建立之前,先搜尋 Store;通常已經有專門的 Actor 存在。

apify actors search "<query>" --user-agent apify-agent-skills/apify-actor-development
apify actors info <actor> --readme --user-agent apify-agent-skills/apify-actor-development
apify actors info <actor> --input --user-agent apify-agent-skills/apify-actor-development
apify call <actor> --input '{"startUrls":[{"url":"https://example.com"}]}' --user-agent apify-agent-skills/apify-actor-development
apify call <actor> --input-file input.json --user-agent apify-agent-skills/apify-actor-development

輸入是一個 JSON 物件。行內 JSON 使用引號包覆;對於複雜的輸入,請使用 --input-file。

較不常見的指令

# 這些指令也請記得附加 --user-agent apify-agent-skills/apify-actor-development。
apify secrets add <name> <value>   # 可從 actor.json 中以 "@name" 方式引用;推送時會上傳
apify pull <actor>                 # 從平台下載 Actor 的程式碼
apify api <endpoint>               # 向 Apify API 發出已認證的請求
apify actor generate-schema-types  # TypeScript:從 .actor 結構描述產生介面,放入 src/__generated__/actor/
apify <command> --help

文件

Individual skills in this repo

This repo contains 13 individual skills — each has its own dedicated page.

nehakanjamala/personal_website

This skill should be used when the user asks to "fix janky CSS animation", "make animation 60fps", "stop layout thrashing", "animate width/height/top/left smoothly", "convert animation to transform", "animate box-shadow performantly", "animate height auto", "FLIP animation", or "why is my scroll/hover animation choppy".

nehakanjamala/personal_website

This skill should be used when the user asks to "respect prefers-reduced-motion", "honor reduced motion", "make my animations accessible", "fix vestibular / motion-sickness issues", "add a useReducedMotion hook", "gate GSAP / Framer Motion / Lenis for reduced motion", or "meet WCAG 2.3.3 / C39". Provides tiered (not all-or-nothing) reduced-motion patterns in CSS and JS.

nehakanjamala/personal_website

Convert existing projects into Apify Actors - serverless cloud programs. Actorize JavaScript/TypeScript (SDK with Actor.init/exit), Python (async context manager), or any language (CLI wrapper). Use when migrating code to Apify, wrapping CLI tools as Actors, or adding Actor SDK to existing projects.

nehakanjamala/personal_website

Deprecated. Output schema generation moved to the apify-actor-development skill; prefer that skill whenever it is available.

nehakanjamala/personal_website

Design and build an official Apify integration for a company's product - workflow-automation apps (Zapier/n8n-style), AI agent plugins (coding-agent skills+MCP bundles or OpenClaw/Hermes-style harnesses), AI framework packages (LangChain/LlamaIndex-style), or direct application clients via apify-client. Use when planning, creating, or reviewing an integration that exposes Apify Actors, runs, datasets, or key-value stores inside another product.

nehakanjamala/personal_website

Universal AI-powered web scraper for any platform. Scrape data from Instagram, Facebook, TikTok, YouTube, LinkedIn, X/Twitter, Google Maps, Google Search, Google Trends, Reddit, Airbnb, Yelp, and 15+ more platforms. Use for lead generation, brand monitoring, competitor analysis, influencer discovery, trend research, content analytics, audience analysis, review analysis, SEO intelligence, recruitment, or any data extraction task.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a glassmorphism effect", "frosted glass UI", "Apple liquid glass style", "frosted blur card", "translucent glass panel animation", "make a frosted nav bar", "build a glass modal/dialog", "animate a glass card on hover", or "add a refracting liquid-glass hero". Covers frosted translucent panels with backdrop-filter blur, edge/specular highlights, SVG liquid-glass refraction, motion on hover/scroll/enter, and accessible reduced-transparency fallbacks.

nehakanjamala/personal_website

This skill should be used when the user asks to "build a scroll animation", "add ScrollTrigger", "pin a section while scrolling", "scrub an animation to scroll", "create a hero timeline", "do a horizontal scroll section", "split text and animate words", "animate a layout change with GSAP Flip", "sync ScrollTrigger with Lenis", "Lenis smooth scroll jittery", "ScrollTrigger markers drift", "ScrollTrigger pins break with Lenis/Locomotive", or "set up smooth scroll with GSAP pinning". Covers GSAP timelines, ScrollTrigger, SplitText, Flip, and Lenis/Locomotive smooth-scroll sync for code-driven web motion.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a Lottie animation", "play a .lottie or .json animation", "integrate a Bodymovin/After Effects animation on web or mobile", "control Lottie playback / segments", "make a scroll-driven Lottie", "recolor a Lottie at runtime", or "export an AE animation to Lottie". Covers dotLottie/lottie-web integration, playback control, interactivity, theming, and the AE export checklist.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a hover/press effect", "animate a toggle or switch", "build an animated like button", "make a toast/snackbar slide in", "animate a drawer or modal", "animate list reordering or add/remove", "do a shared-element layout transition", or "polish UI feedback". Covers UI motion with Framer Motion (motion/react) and modern CSS.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate page or route transitions", "add a page transition or crossfade between views", "animate route changes in Next.js App Router", "use the View Transitions API", "AnimatePresence exit doesn't fire on navigation", or "Framer Motion exit animation not working / exit animation before unmount in Next.js". Covers enter/exit page-transition animation with the View Transitions API and Framer Motion, for Next.js App Router and general SPA routing.

nehakanjamala/personal_website

Scrape web pages using Scrapling with anti-bot bypass (like Cloudflare Turnstile), stealth headless browsing, spiders framework, adaptive scraping, and JavaScript rendering. Use when asked to scrape, crawl, or extract data from websites; web_fetch fails; the site has anti-bot protections; write Python code to scrape/crawl; or write spiders.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate an SVG", "make a line draw itself on", "do a stroke draw-on / signature animation", "morph one shape into another", "move an element along a path", "animate an icon/logo", or "animate an SVG gradient or filter". Covers stroke-dashoffset draw-on, path morphing, motion-along-path, and animated icons/gradients/filters via CSS, SMIL, and GSAP.

相關技能