Skip to main content

A package for scraping websites and converting them to Markdown

Project description


P.E.G.A.S.U.S

~ Parsing Extracting Generating Automated Scraping Utility System ~
PyPI - Version PyPI - Format PyPI - Implementation PyPI - Status PyPI - Downloads PyPI - Downloads GitHub Repo stars forks - Sunwood-ai-labs GitHub Last Commit GitHub Top Language GitHub Release GitHub Tag GitHub Actions Workflow Status

[🌐 Website][🐱 GitHub] [🐦 Twitter][🍀 Official Blog]

[!IMPORTANT] このリポジトリのリリースノートやREADME、コミットメッセージの9割近くはclaude.aiChatGPT4を活用したAIRA, SourceSage, Gaiah, HarmonAI_IIで生成しています。

pegasus は、ウェブサイトを再帰的にクロールし、そのコンテンツを Markdown 形式に変換するパワフルで柔軟な Python パッケージです。指定した URL から始まり、リンクをたどって関連するページを探索し、HTML コンテンツを美しい Markdown ドキュメントに変換します。コマンドラインインターフェイス (CLI) から実行することも、Python スクリプトから直接使用することもできます。

インストール

pip を使用して pegasus をインストールします。

pip install pegasus

使い方

コマンドラインから

pegasus をコマンドラインから使用するには、以下のようなコマンドを実行します。

pegasus https://example.com/start-page output_directory --exclude-selectors header footer nav --include-domain example.com --exclude-keywords login --output-extension txt
pegasus  https://docs.eraser.io/docs/what-is-eraser output/eraser_docs --exclude-selectors header footer nav aside .sidebar .header .footer .navigation .breadcrumbs --include-domain docs.eraser.io --exclude-keywords login --output-extension .txt
  • https://example.com/start-page: クロールを開始するベース URL を指定します。
  • output_directory: Markdown ファイルを保存するディレクトリを指定します。
  • --exclude-selectors: 除外する CSS セレクターをスペース区切りで指定します(オプション)。
  • --include-domain: クロールを特定のドメインに限定します(オプション)。
  • --exclude-keywords: URL に含まれる場合にページを除外するキーワードをスペース区切りで指定します(オプション)。

Python スクリプトから

pegasus を Python スクリプトから使用するには、以下のようなコードを書きます。

from pegasus import pegasus

pegasus = pegasus(
    base_url="https://example.com/start-page",
    output_dir="output_directory",
    exclude_selectors=['header', 'footer', 'nav'],
    include_domain="example.com",
    exclude_keywords=["login"]
)
pegasus.run()
  • base_url: クロールを開始するベース URL を指定します。
  • output_dir: Markdown ファイルを保存するディレクトリを指定します。
  • exclude_selectors: 除外する CSS セレクターのリストを指定します(オプション)。
  • include_domain: クロールを特定のドメインに限定します(オプション)。
  • exclude_keywords: URL に含まれる場合にページを除外するキーワードのリストを指定します(オプション)。

特長

  • 指定した URL から始まり、リンクを再帰的にたどってウェブサイトを探索します。
  • HTML コンテンツを美しくフォーマットされた Markdown に変換します。
  • 柔軟な設定オプションにより、クロールと変換のプロセスをカスタマイズできます。
  • ヘッダー、フッター、ナビゲーションなどの不要な要素を除外できます。
  • 特定のドメインのみをクロールするように制限できます。
  • 特定のキーワードを含む URL を除外できます。

注意事項

  • pegasus は、適切な使用方法とウェブサイトの利用規約に従ってご利用ください。
  • 過度なリクエストを送信しないよう、適切な遅延を設けてください。

ライセンス

このプロジェクトは MIT ライセンスの下で公開されています。詳細については、LICENSE ファイルを参照してください。

貢献

プルリクエストや改善案は大歓迎です。バグ報告や機能リクエストがある場合は、issue を作成してください。


pegasus を使用すれば、ウェブサイトを再帰的に探索し、コンテンツを美しい Markdown ドキュメントに変換できます。ドキュメンテーションの自動化、コンテンツの管理、データ分析などにぜひお役立てください!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pegasus_surf-0.1.1.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

pegasus_surf-0.1.1-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page