Script Examples - JinsongRoh/pydoll-mcp GitHub Wiki

๐Ÿ“œ Script Examples

This guide introduces practical usage examples utilizing the PyDoll MCP Server. These examples demonstrate patterns that AI assistants like Claude can use to perform browser automation through natural language commands.

๐ŸŽฏ Basic Web Automation Examples

1. Website Navigation and Screenshots

"Start a browser and navigate to https://example.com"
"Take a screenshot of the current page"
"Check the page title"

Actual Operations:

  • Create and start browser instance
  • Navigate to specified URL
  • Wait for page load completion
  • Capture full page screenshot
  • Extract page metadata

2. Search Functionality

"Search for 'browser automation' on Google"
"Click the first result link"
"Extract relevant information from the search results page"

Tools Used:

  • navigate_to: URL navigation
  • find_element: Find search box
  • type_text: Enter search terms
  • click_element: Click search button
  • wait_for_page_load: Wait for results page to load

๐Ÿ” Login and Form Automation

3. Website Login

"Navigate to the login page and log in with username '[email protected]' and password 'secure123'"
"Wait until the login success message appears"

Advanced Features:

  • Natural language attribute-based element finding
  • Human-like typing simulation
  • Conditional waiting (success message verification)
  • Error handling (login failure detection)

4. Complex Form Filling

"Find the contact form and fill it with the following information:
- Name: John Smith
- Email: [email protected]
- Message: I have an inquiry
Then submit it"

Features:

  • Multiple input field handling simultaneously
  • Dropdown selection
  • Text area input
  • Form validation handling

๐Ÿ›ก๏ธ Security Bypass and Advanced Features

5. Cloudflare Bypass

"Access a site with Cloudflare protection enabled"
"Automatically solve the Turnstile captcha"
"Access protected content and extract data"

Innovative Features:

  • Automatic Cloudflare Turnstile solving
  • reCAPTCHA v3 bypass
  • Human behavior pattern simulation
  • Bot detection system evasion

6. Stealth Mode Activation

"Activate stealth mode and browse protected sites"
"Randomize browser fingerprint to avoid detection"
"Rotate user agents"

๐Ÿ“Š Data Extraction and Monitoring

7. Dynamic Content Extraction

"Extract all product information from this e-commerce site"
"Include price, name, and review scores in structured data format"
"Wait for AJAX requests to complete before collecting data"

Advanced Data Processing:

  • Dynamic loading content handling
  • JavaScript rendering wait
  • Structured data extraction
  • JSON/CSV format export

8. Network Monitoring

"Monitor all network requests while browsing this website"
"Capture API calls and analyze response data"
"Find API responses containing price information"

Network Control:

  • Real-time traffic analysis
  • Request/response interception
  • API endpoint discovery
  • Header manipulation

๐ŸŽฎ Interactions and Event Handling

9. Advanced Mouse Interactions

"Hover over the product image to display the enlarged image"
"Drag and drop a file to the upload area"
"Right-click to open context menu and select 'Open in new tab'"

Interaction Features:

  • Natural mouse movement
  • Hover effect triggering
  • Drag and drop operations
  • Context menu handling

10. File Upload and Download

"Find the file input field and upload 'document.pdf'"
"Monitor upload progress"
"Click the download link after upload completion"

๐Ÿงช Testing and Quality Assurance

11. Website Performance Testing

"Analyze this website's performance"
"Measure page load time, resource size, and network latency"
"Provide performance improvement suggestions"

Performance Analysis:

  • Page load metrics
  • Resource analysis
  • Network performance
  • Core Web Vitals measurement

12. Cross-Browser Testing

"Run the same test in Chrome and Edge"
"Compare rendering differences between the two browsers"
"Capture screenshots for each browser"

๐Ÿค– AI-Based Automation

13. Intelligent Content Analysis

"Analyze the latest articles from this news website"
"Summarize article content using AI"
"Perform keyword and sentiment analysis"

14. Adaptive Element Finding

"Find the 'Login' button even if the page layout changes"
"Use visual pattern recognition to find similar elements"
"Dynamically identify elements based on text content"

๐Ÿ”ง Advanced Configuration and Customization

15. Browser Environment Customization

"Start browser in headless mode"
"Set viewport to specific resolution (1920x1080)"
"Enable ad blocking functionality"
"Disable all image loading to increase speed"

Environment Configuration:

{
  "browser_config": {
    "headless": true,
    "disable_images": true,
    "block_ads": true,
    "viewport": {"width": 1920, "height": 1080}
  }
}

16. Proxy and Network Settings

"Connect through proxy server"
"Rotate IP addresses while sending multiple requests"
"Customize request headers"
"Limit network speed to simulate slow connections"

๐Ÿ“ฑ Mobile and Responsive Testing

17. Mobile Emulation

"Emulate mobile view with iPhone 14 screen size"
"Simulate touch events for swipe gestures"
"Test if mobile menu works properly"

18. Responsive Design Validation

"Test layout across various screen sizes"
"Take screenshots at different breakpoints"
"Verify elements are properly repositioned"

๐Ÿ”„ Batch Operations and Automation Workflows

19. Multiple Tab Management

"Open 5 different websites simultaneously"
"Collect data in parallel from each tab"
"Consolidate results when all tab operations complete"

20. Scheduling and Monitoring

"Check price changes on this website every hour"
"Save screenshots when changes are detected"
"Send notifications when specific conditions are met"

๐Ÿ’ก Real-World Use Case Scenarios

21. E-commerce Automation

"Analyze search results for 'wireless headphones' on Amazon"
"Filter by price range $50-$100"
"Extract only products with review scores above 4.0"
"Check other sites for price comparison"

22. Social Media Monitoring

"Monitor latest posts with specific hashtags"
"Identify posts with high engagement"
"Collect data for trend analysis"

23. Real Estate Information Gathering

"Collect property listings from real estate sites for specific areas"
"Structure price, area, and location information"
"Automatically notify when new listings are posted"

๐Ÿ› ๏ธ Debugging and Troubleshooting

24. Detailed Logging and Debugging

"Enable debug mode to record detailed logs"
"Save step-by-step screenshots"
"Monitor network activity while diagnosing issues"

25. Error Recovery and Retry

"If element not found, retry with alternative methods"
"Automatically refresh on page load failure"
"Retry with backoff strategy on network errors"

๐Ÿ“‹ Best Practices

Performance Optimization Tips

  • Parallel Processing: Perform simultaneous operations across multiple tabs
  • Resource Limitation: Disable unnecessary images/CSS
  • Cache Utilization: Use cached data for repeated requests
  • Memory Management: Clean up unused tabs/browsers

Security and Ethical Considerations

  • robots.txt Compliance: Check website crawling policies
  • Request Interval Control: Prevent server overload with delays
  • Terms of Service Compliance: Review website service terms
  • Privacy Protection: Handle sensitive data with care

Stability Improvements

  • Exception Handling: Proper error handling for all operations
  • Timeout Settings: Prevent infinite waiting
  • State Validation: Verify success at each step
  • Backup Strategy: Maintain backups of important data

๐Ÿš€ Next Steps

Use these examples as reference to build your own browser automation workflows. PyDoll MCP Server makes complex web automation tasks simple through natural language commands.

For more examples and advanced features:


These examples are based on actual features of PyDoll MCP Server v1.1.3. Experience powerful browser automation while communicating with AI assistants in natural language!