Implementing Domestic AI Coding Tools: Automated Web Scraping in Practice
This article explores the practical application of domestic AI coding tools in automating web data collection tasks. It examines the current limitations of these tools, such as ecosystem gaps in plugins and integrations, and demonstrates their capabilities through a real-world scenario: scraping real estate listings. By detailing the steps from environment setup and API integration to step-by-step agent prompting, the article evaluates the advantages and limitations of AI agents in multi-step task planning, code generation, and debugging.
1. Introduction: Why Haven’t AI Coding Tools Seen Widespread Adoption?
With the rapid development of large language models (LLMs), AI coding tools aimed at “end-to-end automated development” have gained significant attention. Domestic vendors have also launched products with architectures similar to mainstream international tools. However, within enterprises, the actual usage frequency of domestic tools has not yet met expectations.
From practical usage, domestic tools exhibit three main characteristics. First, they have evolved from simple code completion to intelligent agents capable of simple task planning. Second, they offer smooth comprehension of Chinese-language requirements, reducing team communication costs. Third, provided with sufficient context, the initially generated code can reduce manual debugging efforts.
The primary factor limiting their widespread adoption is the ecosystem. Compared to mainstream international tools, domestic tools still lag in plugins, skill components, Model Context Protocol (MCP), and office software integrations. When handling complex business logic, developers often have to manually write bridging code, which diminishes the tool’s practical value.
2. Scenario: Automated Web Data Collection
To evaluate the practical capabilities of AI coding tools, this article selects a specific scenario: scraping real estate listings with price drops. Operations teams often need to acquire structured data from external websites, such as tracking price changes for overseas properties in a specific city.
The difficulty of such tasks lies in the target website’s anti-scraping mechanisms. IP rate limits, CAPTCHAs, and dynamic JavaScript rendering can easily invalidate standard scraping scripts. A common approach is to integrate a third-party web scraping API, letting the service provider handle proxy rotation and dynamic rendering.
The target system functions as follows: users input a city name and price range, and the system scrapes the target site’s listings daily, extracts fields like price, location, and area, filters out listings with price drops for the day, and sends an email alert. This workflow involves external API calls, data processing, conditional logic, and message notifications, making it an excellent test case for an agent’s multi-step planning and code execution capabilities.
3. Implementation Steps
1. Environment Setup and Model Selection
First, install the AI coding tool’s client, then configure the underlying LLM in the settings panel. The quality of the generated code heavily depends on the model’s capability, so selection should be based on actual test results rather than brand recognition alone. It is recommended to test candidate models using the same set of small tasks (e.g., reading JSON, writing an HTTP request function with retry logic), recording whether the code runs successfully, whether it adheres to specified API formats, and how many modifications are required.
| Evaluation Metric | Description | Recording Method |
|---|---|---|
| Model Name & Version | As per service provider docs | Fill in specific version number |
| Context Length | Determines how many API examples and code can be included | Check official parameters |
| Code Task Performance | Pass rate of small tasks | Self-statistics |
| Price & Rate Limits | Affects batch call costs | Based on console billing page |
| Data Compliance | Confirm if input code & logs are used for model training | Read service agreement |
2. Integrating the Scraping API and Building Context
The agent cannot directly bypass the target website’s anti-scraping mechanisms, so a scraping API must be integrated first. Follow these specific steps:
Step 1: Log into the service provider’s console and create an API key in the security settings. Grant this key only the necessary API permissions for the project, and set a usage quota limit.
Step 2: Save the key as an environment variable. Do not hardcode it into the source code or commit it to the repository:
export SCRAPER_API_KEY="your_api_key_here"
Step 3: Locate the specific endpoint for the target site in the provider’s API documentation. The docs typically provide the endpoint URL, authentication method, and request parameters. The code below uses a placeholder URL to demonstrate the call method; replace it with the actual value from the documentation:
import osimport timeimport loggingimport requestsAPI_URL = "https://api.example-scraper.com/v1/listings" # Placeholder URL, please replaceAPI_KEY = os.environ["SCRAPER_API_KEY"]logging.basicConfig(level=logging.INFO)def fetch_listings(city: str, max_price: int, retries: int = 3) -> list[dict]:params = {"city": city, "max_price": max_price, "sort": "price_drop"}headers = {"Authorization": f"Bearer {API_KEY}"}for attempt in range(1, retries + 1):try:resp = requests.get(API_URL, params=params, headers=headers, timeout=15)if resp.status_code == 429:wait = 2 ** attemptlogging.warning("Rate limit triggered, retrying in %s seconds", wait)time.sleep(wait)continueresp.raise_for_status()return resp.json().get("items", [])except requests.RequestException as exc:logging.error("Request %d failed: %s", attempt, exc)time.sleep(2 ** attempt)raise RuntimeError("Scraping API failed multiple times. Check network, quota, and API key.")
The code only logs exception details and omits request headers to prevent the API key from appearing in logs. Field names in the response (such as items, price, old_price, district, area, url) are examples only; refer to the provider’s documentation and actual returns.
Common API response statuses and handling methods are as follows:
| Status | Meaning | Handling Method |
|---|---|---|
| 401 / 403 | Invalid key or insufficient permissions | Check key & permissions, do not retry |
| 429 | Rate limit exceeded | Retry with exponential backoff |
| 5xx | Server-side exception | Limited retries, log the issue |
| 200 with empty items | No results for filters, or page structure changed | Log query conditions, verify manually |
Once these preparations are complete, place the API documentation summary, sample code, and response field descriptions into the agent’s project context file. The agent can then write parsing logic based on actual fields, reducing the chance of fabricating parameters.
3. From Requirements to Code: Step-by-Step Agent Execution
Unlike line-by-line manual code completion, an agent can receive a relatively complete requirement and decompose the task itself. The prompting in this article is divided into three stages:
Stage 1: Request a Product Requirements Document (PRD), including inputs, outputs, module breakdown, and exception scenarios.
Stage 2: Request the main logic, including API calls, response parsing, price-drop evaluation, and email sending. Require that all keys and email configurations be read from environment variables.
Stage 3: Request test cases covering four scenarios: empty results, rate limiting, invalid keys, and email sending failures.
Example prompt:
Please implement the following features based on the provided API documentation and sample code:Input: City name, maximum price.Processing: Call the scraping API, parse the "items" field, filter listings where old_price > price.Output: Send an email if there are listings with price drops; log if no results.Constraints: Read all keys and email configurations from environment variables; do not log request headers; do not fabricate API fields.List any assumptions that require manual confirmation upon completion.
Human review checkpoints should be set at each stage. The PRD requires developers to confirm business rules, such as the threshold for price drops and deduplication rules. The generated code must be checked item by item for API parameters and exception branches. After tests pass, a small-scale scrape using the real API should be conducted in the test environment to verify that the results match the webpage display.
In actual operation, the agent’s initial draft reduces repetitive coding time, but issues like misunderstanding API fields or missing boundary conditions can still occur. Efficiency gains should be evaluated comprehensively based on task complexity, context quality, and manual review costs.
4. Advantages and Limitations
The table below summarizes the performance, applicable boundaries, and alternative solutions across different dimensions in this practice.
| Dimension | Performance | Applicable Boundary | Alternative or Supplementary Solutions |
|---|---|---|---|
| Task Planning | Can break requirements into PRD, code, and tests | Works well when requirements are clear and API docs are complete | Manually write acceptance criteria for complex needs first |
| Chinese Comprehension | Smooth understanding of Chinese requirements | Effective for Chinese-first teams or contexts | Use international models with strong multilingual support |
| Ecosystem & Integration | Requires manual bridging code for complex workflows | Best for isolated, self-contained tasks | Manually integrate necessary plugins or MCP components |
