Skip to main content

Sync-First бібліотека для побудови графу веб-сайтів - просто як requests!

Project description

GraphCrawler

Python 3.11+ PyPI License: MIT

Бібліотека для побудови графу структури веб-сайтів.

Встановлення

pip install graph-crawler

Додаткові залежності:

pip install graph-crawler[playwright]    # JavaScript сайти
pip install graph-crawler[embeddings]    # Векторизація
pip install graph-crawler[mongodb]       # MongoDB storage
pip install graph-crawler[all]           # Все

Використання

import graph_crawler as gc

# Базове сканування
graph = gc.crawl("https://example.com", max_depth=2, max_pages=50)

print(f"Сторінок: {len(graph.nodes)}")
print(f"Посилань: {len(graph.edges)}")

# Збереження
gc.save_graph(graph, "site.json")

Async API

import asyncio
import graph_crawler as gc

async def main():
    graph = await gc.async_crawl("https://example.com")
    return graph

graph = asyncio.run(main())

Параметри crawl()

Параметр Default Опис
max_depth 3 Глибина сканування
max_pages 100 Ліміт сторінок
same_domain True Тільки поточний домен
request_delay 0.5 Затримка між запитами (сек)
timeout 300 Загальний таймаут (сек)
driver "http" Драйвер: http, playwright

URL Rules

from graph_crawler import crawl, URLRule

rules = [
    URLRule(pattern=r"\.pdf$", should_scan=False),
    URLRule(pattern=r"/admin/", should_scan=False),
    URLRule(pattern=r"/products/", priority=10),
]

graph = crawl("https://example.com", url_rules=rules)

Операції з графом

# Статистика
stats = graph.get_stats()

# Пошук
node = graph.get_node_by_url("https://example.com/page")

# Об'єднання графів
merged = graph1 + graph2

# Експорт
graph.export_edges("edges.csv", format="csv")
graph.export_edges("graph.dot", format="dot")

Драйвери

Драйвер Призначення
http Статичні сайти (default)
playwright JavaScript/SPA сайти
# Playwright для JS сайтів
graph = gc.crawl("https://spa-site.com", driver="playwright")

Storage

Тип Рекомендовано
memory < 1K сторінок
json 1K - 20K сторінок
sqlite 20K+ сторінок
mongodb Великі проекти

CLI

graph-crawler crawl https://example.com --max-depth 2
graph-crawler list
graph-crawler info graph_name

Вимоги

  • Python 3.11+

Ліцензія

MIT

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

graph_crawler-4.0.24.tar.gz (739.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_crawler-4.0.24-py3-none-any.whl (895.6 kB view details)

Uploaded Python 3

File details

Details for the file graph_crawler-4.0.24.tar.gz.

File metadata

  • Download URL: graph_crawler-4.0.24.tar.gz
  • Upload date:
  • Size: 739.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for graph_crawler-4.0.24.tar.gz
Algorithm Hash digest
SHA256 cc0c813382cafeef1f560655bcc55662aa4169f0975e0ea4dd636d42addf9493
MD5 97c6b021c92a5c882200982d40df024b
BLAKE2b-256 836a1e17c9023a462088d07ea61bed4700ed1e7b2e8351c210ba0ca08c602f58

See more details on using hashes here.

File details

Details for the file graph_crawler-4.0.24-py3-none-any.whl.

File metadata

  • Download URL: graph_crawler-4.0.24-py3-none-any.whl
  • Upload date:
  • Size: 895.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for graph_crawler-4.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 9481829af3168c211f1884fdda9d465b401fd17e3d642caca5490e53878484ac
MD5 8add9d74de15d16129c06c5c07deec2f
BLAKE2b-256 716cf9f889c56e582fee9f93c2f1d3fa72de6d6b4e490a37643ea2af80eebbd1

See more details on using hashes here.

Supported by

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