mirror of
https://github.com/actionbook/actionbook.git
synced 2026-09-19 03:28:06 +08:00
8207d6f012
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Actionbook CLI Examples
This directory contains example scripts demonstrating how to use the Actionbook CLI.
Examples
1. Etsy Valentine's Day Exploration
Demonstrates a complete workflow for exploring Etsy's Valentine's Day content using both the Actionbook API and browser automation.
# Make executable and run
chmod +x etsy_valentine_exploration.sh
./etsy_valentine_exploration.sh
What it does:
- Searches Actionbook database for Etsy-related actions
- Searches for Valentine's Day content
- Retrieves detailed action with CSS/XPath selectors
- Opens Etsy in browser
- Navigates to Valentine's Day pages
- Takes screenshots
- Executes JavaScript to get page title
Common Workflows
Search + Get Pattern
The most common pattern for using Actionbook is:
# 1. Search for actions related to your target site
actionbook search "airbnb login" --limit 5
# 2. Get detailed action with selectors
actionbook get "https://www.airbnb.com/login"
# 3. Use the selectors in your automation
Browser Automation Pattern
# 1. Open browser with URL
actionbook browser open "https://example.com"
# 2. Interact with elements
actionbook browser click "button.submit"
actionbook browser type "input[name=email]" "user@example.com"
actionbook browser fill "input[name=password]" "secret"
# 3. Wait for navigation
actionbook browser wait ".success-message"
# 4. Take screenshot for verification
actionbook browser screenshot result.png
Actionbook + Browser Combined
#!/bin/bash
# Use Actionbook selectors to automate login
# Get the action with selectors
ACTION=$(actionbook get "https://www.airbnb.com/login" --json)
# Extract selectors (example with jq)
EMAIL_SELECTOR=$(echo "$ACTION" | jq -r '.elements[] | select(.id=="input_email") | .css')
PASSWORD_SELECTOR=$(echo "$ACTION" | jq -r '.elements[] | select(.id=="input_password") | .css')
SUBMIT_SELECTOR=$(echo "$ACTION" | jq -r '.elements[] | select(.id=="button_submit") | .css')
# Automate the login
actionbook browser open "https://www.airbnb.com/login"
sleep 2
actionbook browser fill "$EMAIL_SELECTOR" "user@example.com"
actionbook browser fill "$PASSWORD_SELECTOR" "password123"
actionbook browser click "$SUBMIT_SELECTOR"
Output Formats
Default (Human-readable)
$ actionbook search "etsy" --limit 2
✓ Found 2 results for: etsy
1. ID: https://www.etsy.com/your/shops/me/listing-editor/create
Score: 1.00
# Etsy Listing Creation Page
2. ID: https://www.ebay.com/b/{category-name}/bn_{bn-id}
Score: 0.49
# Playbook: eBay Brand Outlet Page
JSON Format
$ actionbook search "etsy" --limit 2 --json
[
{
"action_id": "https://www.etsy.com/your/shops/me/listing-editor/create",
"score": 1.0,
"content": "# Etsy Listing Creation Page..."
}
]
Multi-Profile Usage
# Create profiles for different use cases
actionbook profile create personal
actionbook profile create work
# Use specific profile
actionbook --profile work browser open "https://work-app.com"
actionbook --profile personal browser open "https://social-media.com"
# Each profile has isolated:
# - Cookies
# - Local storage
# - Browser history
# - Session data
Environment Variables
# Set API endpoint
export ACTIONBOOK_API_URL="https://api.actionbook.dev"
# Run in headless mode
export ACTIONBOOK_HEADLESS=true
# Connect to existing browser
export ACTIONBOOK_CDP_PORT=9222
# Now commands use these settings
actionbook browser open "https://example.com"
Tips
- Use
--jsonfor scripting - Easier to parse in scripts - Use profiles for isolation - Keep work/personal sessions separate
- Check browser status first -
actionbook browser statusshows connection info - Combine search + get - Search finds actions, get retrieves selectors
- Use headless for CI/CD - Add
--headlessflag for automated pipelines