mcpField
S
scrape-ensure-project

scrape-ensure-project

github.com/zytedata開発11167 回インストール2 日前に更新
リポジトリ

scrape-ensure-project について

scrape-ensure-projectは、web-poetのページオブジェクトとZyte API向けに設定されたScrapyプロジェクトを作成または確認するスキルです。テンプレートから新規作成するほか、既存プロジェクトの依存関係も確認します。

主な機能

  1. 01テンプレートからプロジェクトを作成
  2. 02scrapy-poetとZyte APIを設定
  3. 03既存プロジェクトの依存関係を確認
  4. 04fixturesディレクトリの有無を確認

活用シーン

  1. 01ページオブジェクト用Scrapyプロジェクトの開始
  2. 02既存プロジェクトの依存関係の確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/zytedata/skills --skill scrape-ensure-project

インストール後、Claude Code で/scrape-ensure-projectを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

assets/project-template/
cookiecutter.json
assets/project-template/{{cookiecutter.project_name}}/
pyproject.toml
scrapy.cfg
assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/
__init__.py
items.py
settings.py
assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/pages/
__init__.py
assets/project-template/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}/spiders/
__init__.py
assets/project-template/{{cookiecutter.project_name}}/fixtures/
.gitkeep

詳細

Scrapy プロジェクトが存在し、web-poet のページオブジェクトと Zyte API 用に適切に設定されていることを確認します。

${CLAUDE_SKILL_DIR}/../scrape/references/python-environments.md を読みます。

入力

生の引数文字列は $ARGUMENTS です。空白で区切られた位置引数 2 つに分割します。

  1. project_dir:プロジェクトディレクトリ(例:./books-project)
  2. project_name:Python パッケージ名(例:books_project)

手順

1. プロジェクトがすでに存在するか確認する

{project_dir}/pyproject.toml が存在する場合、既存のプロジェクトです。手順 3 に進みます。

それ以外の場合は、手順 2 でプロジェクトを新規作成します。

2. 新しいプロジェクトを作成する

バンドルされている cookiecutter テンプレートを使用します。

uvx cookiecutter --no-input ${CLAUDE_SKILL_DIR}/assets/project-template -o PARENT_DIR project_name=PROJECT_NAME

これにより、次の内容を含む Scrapy プロジェクトが作成されます。

  • 依存関係(scrapy、scrapy-poet、scrapy-zyte-api、web-poet)を記載した pyproject.toml
  • デプロイ設定を含む scrapy.cfg
  • scrapy-poet と Zyte API のアドオンを設定した settings.py
  • pages/、spiders/、fixtures/ ディレクトリ
  • アイテムクラスを追加できる空の items.py

次に、インストールします。

cd PROJECT_DIR && uv sync

作成したものを報告して終了します。

3. 既存プロジェクトの依存関係を確認する

プロジェクトの pyproject.toml を読み、次のパッケージが dependencies に含まれていることを確認します。

  • scrapy
  • scrapy-poet
  • web-poet
  • extruct
  • price-parser
  • pytest

不足しているものがあれば、ユーザーに警告します。不足している依存関係を列挙し、 追加するかどうかを確認します。確認を得る前にプロジェクトを変更してはいけません。

また、fixtures/ ディレクトリが存在することも確認します(存在しない場合は作成します。単なる ディレクトリです)。

4. 結果を報告する

新しいプロジェクトの場合:

Created project at {project_dir}:
  - {project_name}/settings.py — scrapy-poet + Zyte API configured
  - {project_name}/items.py — ready for item classes
  - {project_name}/pages/ — ready for page objects
  - fixtures/ — ready for test fixtures

既存のプロジェクトの場合:

Using existing project at {project_dir}.

依存関係が不足している場合:

Using existing project at {project_dir}.
Warning: missing dependencies: {list}
Add them to pyproject.toml?

コメント