Skip to main content

Extractor web

Los LLM no pueden acceder directamente a los datos de páginas web. El extractor web accede a una URL y extrae su contenido para el modelo.

Uso

El extractor web se puede invocar de cuatro maneras. Los parámetros requeridos difieren para cada método:
  • Compatible con OpenAI - Responses API
  • Compatible con OpenAI - Chat Completions API
  • DashScope
  • Compatible con Anthropic
Agregue web_search y web_extractor al parámetro tools.
Para obtener una mayor precisión en problemas matemáticos o de análisis de datos, habilite también la herramienta code_interpreter.
# Import dependencies and create a client...
response = client.responses.create(
    model="qwen3.8-max",
    input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    tools=[
        # To enable web extraction, also enable the web search tool
        {"type": "web_search"},
        {"type": "web_extractor"},
        {"type": "code_interpreter"}
    ],
    extra_body={
      # Thinking mode must be enabled
      "enable_thinking": True
    }
)

print(response.output_text)

Modelos admitidos

deepseek-v4.1-flash-1017 admite la herramienta integrada web_extractor en la Responses API y web_fetch en la API compatible con Anthropic en las seis regiones y los alcances de implementación correspondientes indicados en la página del modelo. kimi-k3.1-pro (implementado en Alibaba Cloud Model Studio) admite la herramienta integrada web_extractor en la Responses API y web_fetch en la API compatible con Anthropic en Pekín, Singapur, EE. UU. (Virginia), Alemania (Fráncfort), Japón (Tokio) y China (Hong Kong).

Modelos recomendados

  • API de respuestas
  • Chat Completions API / DashScope
Qwen-Max: qwen4-max-preview (solo Token Plan), serie Qwen3.8-Max, serie Qwen3.7-MaxQwen-Plus: serie Qwen3.7-Plus, serie Qwen3.6-Plus, serie Qwen3.5-PlusDeepSeek: deepseek-v4-flash-0731, deepseek-v4-proGLM: glm-5.2Serie de código abierto Qwen3.8

Otros modelos

Los siguientes modelos también admiten esta herramienta, pero es posible que no tengan un rendimiento tan bueno como los modelos recomendados. Solo se admite a través de la Responses API.
  • Qwen-Flash: serie Qwen3.7-Flash, serie Qwen3.6-Flash, serie Qwen3.5-Flash
  • Serie de código abierto Qwen3.6 (excepto qwen3.6-27b)
  • Serie de código abierto Qwen3.5

Introducción

Este ejemplo invoca el extractor web a través de la Responses API para resumir un documento técnico.
Debe obtener una clave de API y configurarla como variable de entorno.
import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the next line with api_key="sk-xxx", using your Model Studio API key.
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)

response = client.responses.create(
    model="qwen3.8-max",
    input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    tools=[
        {
            "type": "web_search"
        },
        {
            "type": "web_extractor"
        },
        {
            "type": "code_interpreter"
        }
    ],
    extra_body = {
        "enable_thinking": True
    }
)
# Uncomment the following line to view intermediate process outputs
# print(response.output)
print("="*20+"Response Content"+"="*20)
print(response.output_text)
# Print the number of tool calls
usage = response.usage
print("="*20+"Tool Call Count"+"="*20)
if hasattr(usage, 'x_tools') and usage.x_tools:
    print(f"\nWeb extraction count: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")
Salida de ejemplo:
====================Response Content====================
Based on the official Alibaba Cloud Model Studio documentation, I have summarized the core content of the **code interpreter** feature for you:

## 1. Feature Positioning

...

> **Document Source**: Alibaba Cloud Model Studio official documentation - [Qwen Code Interpreter](https://www.alibabacloud.com/help/model-studio/qwen-code-interpreter) and [Assistant API Code Interpreter](https://www.alibabacloud.com/help/model-studio/code-interpreter) (Updated: December 2025)
====================Tool Call Count====================

Web extraction count: 1

Salida por secuencias

La extracción web puede llevar mucho tiempo. Habilite la salida de transmisión para recibir resultados intermedios en tiempo real.
Utilice la Responses API para recuperar el estado de ejecución intermedio de la herramienta.
  • Compatible con OpenAI - Responses API
  • Compatible con OpenAI - Chat Completions API
  • DashScope
import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the next line with api_key="sk-xxx" (not recommended), using your Model Studio API key.
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # Singapore region. Replace {WorkspaceId} with your actual Workspace ID. URLs vary by region.
    base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)

stream = client.responses.create(
    model="qwen3.8-max",
    input="Please visit the official Alibaba Cloud Model Studio documentation for the code interpreter and summarize its main content",
    tools=[
        {"type": "web_search"},
        {"type": "web_extractor"},
        {"type": "code_interpreter"}
    ],
    stream=True,
    extra_body={"enable_thinking": True}
)

reasoning_started = False
output_started = False

for chunk in stream:
    # Print the thinking process
    if chunk.type == 'response.reasoning_text.delta':
        if not reasoning_started:
            print("="*20 + "Thinking Process" + "="*20)
            reasoning_started = True
        print(chunk.delta, end='', flush=True)
    # Print when tool call is complete
    elif chunk.type == 'response.output_item.done':
        if hasattr(chunk, 'item') and hasattr(chunk.item, 'type'):
            if chunk.item.type == 'web_extractor_call':
                print("\n" + "="*20 + "Tool Call" + "="*20)
                print(chunk.item.goal)
                print(chunk.item.output)
            elif chunk.item.type == 'reasoning':
                reasoning_started = False
    # Print the response content
    elif chunk.type == 'response.output_text.delta':
        if not output_started:
            print("\n" + "="*20 + "Response Content" + "="*20)
            output_started = True
        print(chunk.delta, end='', flush=True)
    # When the response is complete, print the number of tool calls
    elif chunk.type == 'response.completed':
        print("\n" + "="*20 + "Tool Call Count" + "="*20)
        usage = chunk.response.usage
        if hasattr(usage, 'x_tools') and usage.x_tools:
            print(f"Web extraction count: {usage.x_tools.get('web_extractor', {}).get('count', 0)}")
            print(f"Web search count: {usage.x_tools.get('web_search', {}).get('count', 0)}")

Facturación

La facturación incluye:
  • Tarifas de llamada del modelo: El contenido extraído de la página web se agrega al prompt, lo que aumenta el recuento de tokens de entrada. Estos tokens se facturan a la tarifa estándar del modelo. Para obtener detalles sobre los precios, consulte la consola de Model Studio.
  • Tarifas de llamada de herramientas: Incluye extracción web y búsqueda web.
    • Tarifas de búsqueda web por 1,000 llamadas:
      • Regiones de China (Pekín), EE. UU. (Virginia), China (Hong Kong), Japón (Tokio) y Alemania (Fráncfort): $0.57341.
      • Región de Singapur: $10.00.
    • El extractor web es gratuito por tiempo limitado.