A skill for automating search operations on DeepSeek (AI assistant) using AppleScript + JavaScript to bypass CDP restrictions.
This skill provides a reliable way to extract search results from DeepSeek without relying on unstable CDP (Chrome DevTools Protocol) connections. It uses macOS system APIs combined with browser JavaScript injection to overcome the limitations of traditional browser automation tools when working with DeepSeek's dynamic SPA application.
Traditional browser automation tools (like Playwright, Puppeteer, or OpenClaw's browser tool) often fail with DeepSeek because:
- CDP Connection Instability: DeepSeek's dynamic page updates frequently disconnect CDP sessions
- Security Restrictions: DeepSeek may block remote debugging protocols
- Dynamic Content: Search results are generated dynamically after page load
This skill bypasses these issues by:
- Using AppleScript: Controls Chrome at the macOS system level
- JavaScript Injection: Extracts content directly from page DOM
- Content Pattern Matching: Locates search results by text patterns
- System-Level Automation: No dependency on CDP connections
- macOS (requires AppleScript support)
- Google Chrome installed
- OpenClaw browser extension installed and attached to DeepSeek tab
-
Ensure the skill is in your OpenClaw skills directory:
~/.openclaw/workspace/skills/deepseek-search/ -
Make scripts executable:
chmod +x ~/.openclaw/workspace/skills/deepseek-search/scripts/*.sh
When you need to search DeepSeek:
- Activate the skill: Mention "deepseek search" or similar keywords
- Follow the workflow:
- Skill will guide you to open DeepSeek page in Chrome
- You'll manually enter the search query (due to CDP limitations)
- Skill will extract and format the results
# Extract content from already-searched DeepSeek page
./scripts/deepseek_search.sh
# Extract with cleaning
./scripts/deepseek_search.sh --clean
# Verbose output
./scripts/deepseek_search.sh --verbosefrom scripts.deepseek_search import search_deepseek
# Search and extract results
result = search_deepseek("广州旅游景点推荐", clean=True, verbose=True)
if result['success']:
print(result['content'])
print(f"Extracted {result['length']} characters in {result['elapsed_time']:.2f} seconds")
else:
print(f"Error: {result['error']}")- Manual Step: Open Chrome, navigate to DeepSeek page
- Manual Step: Enter your search query and press Enter
- Automated Step: Run the skill to extract results:
./scripts/deepseek_search.sh --clean --verbose
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AppleScript │ │ JavaScript │ │ Content │
│ (macOS) │───▶│ (Chrome) │───▶│ Processing │
│ │ │ │ │ (Python) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
Find Chrome tab Extract page text Clean & structure
Activate window Locate results Format output
Execute JS Filter content
- Tab Location: AppleScript finds Chrome tab with DeepSeek URL
- Window Activation: Brings Chrome window to foreground
- JavaScript Execution: Injects script to extract page content
- Content Targeting: Locates search results by text patterns
- Data Extraction: Captures the relevant content section
- Cleaning: Removes navigation, ads, and irrelevant elements
- Output: Returns structured, cleaned content
The core extraction script:
// 1. Get all text from page
var text = document.body.innerText;
// 2. Find search query in text
var start = text.indexOf("搜索关键词");
// 3. Find end of content (look for markers)
var end = text.indexOf("参考") || text.indexOf("我可以帮你");
// 4. Extract and clean
return text.substring(start, end).trim();Arguments:
--clean: Remove navigation and non-content elements--verbose,-v: Show detailed progress information--help,-h: Show help message
Environment Variables:
DEEPSEEK_DEBUG: Set to1for debug outputDEEPSEEK_OUTPUT_DIR: Custom output directory (default:/tmp)
Main Functions:
search_deepseek(query, clean=True, verbose=False): Main search functionextract_content(query=None): Extract content from current pageclean_content(content, query=None): Clean and format extracted contentfind_deepseek_tab(): Locate DeepSeek tab in Chrome
Classes:
DeepSeekSearchError: Custom exception for search errors
The skill handles common errors:
- Tab Not Found: Checks if DeepSeek page is open in Chrome
- No Content: Verifies search results are present
- JavaScript Error: Falls back to alternative extraction methods
- System Errors: Checks macOS and Chrome availability
- macOS Only: Requires AppleScript (no Windows/Linux support)
- Chrome Required: Only tested with Google Chrome
- Manual Input: Cannot automate typing due to CDP limitations
- Cannot automatically enter search queries (requires manual typing)
- May miss some content if page structure changes
- Requires OpenClaw browser extension for initial setup
Planned improvements:
- Cross-Platform Support: Add Windows (PowerShell) and Linux (DBus) alternatives
- Auto-Search: Integrate with system automation to type queries
- Enhanced Extraction: Better AI-powered content recognition
- Batch Processing: Support multiple sequential searches
- API Server: REST API for remote DeepSeek search
"DeepSeek tab not found"
- Ensure Chrome is running with DeepSeek tab open
- Verify URL is correct
- Check OpenClaw browser extension is attached (badge shows ON)
"No content extracted"
- Wait for DeepSeek to finish generating response
- Try
--cleanflag to filter non-content elements - Check if search query was properly entered
AppleScript permissions
- Grant Accessibility permissions to Terminal/OpenClaw
- System Preferences → Security & Privacy → Privacy → Accessibility
Enable debug output:
DEEPSEEK_DEBUG=1 ./scripts/deepseek_search.sh --verbosebrowser-use: General browser automationwebsearch-deep: Deep web research capabilitiesexa-web-search-free: Alternative search methods
- Fork the repository
- Create feature branch
- Submit pull request
MIT License
Developed based on successful implementation of DeepSeek search automation that bypasses CDP limitations using AppleScript + JavaScript.
- Initial release
- AppleScript + JavaScript extraction
- Content cleaning and formatting
- Shell and Python interfaces