[BUG] ScrapeElementFromWebsiteTool breaks when only website_url or only css_element is set at init

オープン
#9,873 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@p-tirth がすでに取り組んでいます。

2026年11月27日 から。

  • #9874 @p-tirth による — オープン
  • #9890 @Mansi2221 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

The issue names ScrapeElementFromWebsiteTool and SeleniumScrapingTool but no source or test file paths. Start by locating the tool implementation and its tests, then check how initialization selects the argument schema and stores each fixed value. Done means either initialization option can be fixed independently, the remaining argument is requested, and tests cover both cases.

索引モデルが issue の本文から書いたものです。

説明

Description

The docs for ScrapeElementFromWebsiteTool describe website_url and css_element as independently optional at initialization: "If provided during initialization, the agent won't need to specify it when using the tool." That only holds when both are given. Fixing just one of them breaks the tool.

  • Only website_url fixed: the tool switches to the empty FixedScrapeElementFromWebsiteToolSchema, so the agent is never asked for css_element and every run raises Both website_url and css_element must be provided.
  • Only css_element fixed: the value is dropped, because it is only stored inside if website_url is not None:. The agent is still asked for a selector.
Steps to Reproduce
from unittest.mock import MagicMock, patch
from crewai_tools import ScrapeElementFromWebsiteTool

MODULE = "crewai_tools.tools.scrape_element_from_website.scrape_element_from_website"
page = MagicMock(content=b"<html><h1>Title</h1><p class='price'>$10</p></html>")

with patch(f"{MODULE}.safe_get", return_value=page):
    a = ScrapeElementFromWebsiteTool(website_url="https://example.com")
    print(list(a.args_schema.model_fields))   # []
    a.run()                                   # ValueError: Both website_url and css_element must be provided.

    b = ScrapeElementFromWebsiteTool(css_element=".price")
    print(b.css_element)                      # None
    print(list(b.args_schema.model_fields))   # ['website_url', 'css_element']
Expected behavior
  • With only website_url fixed, the schema asks the agent for css_element.
  • With only css_element fixed, the selector is kept and the schema asks the agent for website_url.

SeleniumScrapingTool already stores css_element on its own, outside the website_url check.

Environment
  • crewAI and crewAI Tools 1.15.45 (main at 77237ae)
  • Python 3.13, macOS
Possible Solution

Store css_element independently and pick the args schema from what was fixed at init. I have this ready with tests and will open a PR.

Additional context

I used an AI coding assistant while working on this.

主要言語
Python
スター
61.2k
フォーク
9.2k
平均マージ
1日 14時間
マージ済み PR(30日)
180

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。