
Google Search
STDIOPlaywright-based tool for bypassing Google anti-scraping mechanisms and executing real-time searches
Playwright-based tool for bypassing Google anti-scraping mechanisms and executing real-time searches
A Playwright-based Node.js tool that bypasses search engine anti-scraping mechanisms to execute Google searches and extract results. It can be used directly as a command-line tool or as a Model Context Protocol (MCP) server to provide real-time search capabilities to AI assistants like Claude.
# Install from source git clone https://github.com/web-agent-master/google-search.git cd google-search # Install dependencies npm install # Or using yarn yarn # Or using pnpm pnpm install # Compile TypeScript code npm run build # Or using yarn yarn build # Or using pnpm pnpm build # Link package globally (required for MCP functionality) npm link # Or using yarn yarn link # Or using pnpm pnpm link
This tool has been specially adapted for Windows environments:
.cmd
files are provided to ensure command-line tools work properly in Windows Command Prompt and PowerShell/tmp
directory# Direct command line usage google-search "search keywords" # Using command line options google-search --limit 5 --timeout 60000 --no-headless "search keywords" # Or using npx npx google-search-cli "search keywords" # Run in development mode pnpm dev "search keywords" # Run in debug mode (showing browser interface) pnpm debug "search keywords" # Get raw HTML of search result page google-search "search keywords" --get-html # Get HTML and save to file google-search "search keywords" --get-html --save-html # Get HTML and save to specific file google-search "search keywords" --get-html --save-html --html-output "./output.html"
-l, --limit <number>
: Result count limit (default: 10)-t, --timeout <number>
: Timeout in milliseconds (default: 60000)--no-headless
: Show browser interface (for debugging)--remote-debugging-port <number>
: Enable remote debugging port (default: 9222)--state-file <path>
: Browser state file path (default: ./browser-state.json)--no-save-state
: Don't save browser state--get-html
: Retrieve raw HTML of search result page instead of parsing results--save-html
: Save HTML to file (used with --get-html)--html-output <path>
: Specify HTML output file path (used with --get-html and --save-html)-V, --version
: Display version number-h, --help
: Display help information{ "query": "deepseek", "results": [ { "title": "DeepSeek", "link": "https://www.deepseek.com/", "snippet": "DeepSeek-R1 is now live and open source, rivaling OpenAI's Model o1. Available on web, app, and API. Click for details. Into ..." }, { "title": "DeepSeek", "link": "https://www.deepseek.com/", "snippet": "DeepSeek-R1 is now live and open source, rivaling OpenAI's Model o1. Available on web, app, and API. Click for details. Into ..." }, { "title": "deepseek-ai/DeepSeek-V3", "link": "https://github.com/deepseek-ai/DeepSeek-V3", "snippet": "We present DeepSeek-V3, a strong Mixture-of-Experts (MoE) language model with 671B total parameters with 37B activated for each token." } // More results... ] }
When using the --get-html
option, the output will include information about the HTML content:
{ "query": "playwright automation", "url": "https://www.google.com/", "originalHtmlLength": 1291733, "cleanedHtmlLength": 456789, "htmlPreview": "<!DOCTYPE html><html itemscope=\"\" itemtype=\"http://schema.org/SearchResultsPage\" lang=\"zh-CN\"><head><meta charset=\"UTF-8\"><meta content=\"dark light\" name=\"color-scheme\"><meta content=\"origin\" name=\"referrer\">..." }
If you also use the --save-html
option, the output will include the path where the HTML was saved:
{ "query": "playwright automation", "url": "https://www.google.com/", "originalHtmlLength": 1292241, "cleanedHtmlLength": 458976, "savedPath": "./google-search-html/playwright_automation-2025-04-06T03-30-06-852Z.html", "screenshotPath": "./google-search-html/playwright_automation-2025-04-06T03-30-06-852Z.png", "htmlPreview": "<!DOCTYPE html><html itemscope=\"\" itemtype=\"http://schema.org/SearchResultsPage\" lang=\"zh-CN\">..." }
This project provides Model Context Protocol (MCP) server functionality, allowing AI assistants like Claude to directly use Google search capabilities. MCP is an open protocol that enables AI assistants to safely access external tools and data.
# Build the project pnpm build
Edit the Claude Desktop configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
C:\Users\username\AppData\Roaming\Claude\claude_desktop_config.json
%APPDATA%\Claude
in Windows Explorer address barAdd server configuration and restart Claude
{ "mcpServers": { "google-search": { "command": "npx", "args": ["google-search-mcp"] } } }
For Windows environments, you can also use the following configurations:
{ "mcpServers": { "google-search": { "command": "cmd.exe", "args": ["/c", "npx", "google-search-mcp"] } } }
{ "mcpServers": { "google-search": { "command": "node", "args": ["C:/path/to/your/google-search/dist/src/mcp-server.js"] } } }
Note: For the second method, you must replace C:/path/to/your/google-search
with the actual full path to where you installed the google-search package.
After integration, you can directly use search functionality in Claude, such as "search for the latest AI research".
google-search/
├── package.json # Project configuration and dependencies
├── tsconfig.json # TypeScript configuration
├── src/
│ ├── index.ts # Entry file (command line parsing and main logic)
│ ├── search.ts # Search functionality implementation (Playwright browser automation)
│ ├── mcp-server.ts # MCP server implementation
│ └── types.ts # Type definitions (interfaces and type declarations)
├── dist/ # Compiled JavaScript files
├── bin/ # Executable files
│ └── google-search # Command line entry script
├── README.md # Project documentation
└── .gitignore # Git ignore file
All commands can be run in the project root directory:
# Install dependencies pnpm install # Install Playwright browsers pnpm run postinstall # Compile TypeScript code pnpm build # Clean compiled output pnpm clean
# Run in development mode pnpm dev "search keywords" # Run in debug mode (showing browser interface) pnpm debug "search keywords" # Run compiled code pnpm start "search keywords" # Test search functionality pnpm test
# Run MCP server in development mode pnpm mcp # Run compiled MCP server pnpm mcp:build
The tool has built-in robust error handling mechanisms:
.google-search-browser-state.json
google-search-logs
folderCompared to paid search engine results API services (such as SerpAPI), this project offers the following advantages: