Skip to main content

Utility tools for Desync AI users

Project description

desync-data

Utility functions for working with PageData objects from the desync_search library. These tools help you clean, filter, deduplicate, extract links, compute text stats, and export structured data from websites crawled via Desync.


🚀 Features

  • 🔍 Remove boilerplate from page content (prefix/suffix delimiters)
  • 📌 Filter pages by URL substring
  • 🧹 Remove duplicate pages (based on text_content)
  • 🔗 Extract link graphs (internal navigation structure)
  • 📊 Compute text statistics (word count, link density, etc.)
  • 📤 Export pages to CSV, JSON, or SQLite

📦 Installation

pip install desync-data

🧪 Quick Example

from desync_search import DesyncClient
from desync_data import *

client = DesyncClient(api_key="your_api_key")
pages = client.crawl("https://example.com", max_depth=2)

pages = remove_duplicate_pages(pages)
pages = remove_boilerplate_prefix(pages, "START")
pages = remove_boilerplate_suffix(pages, "FOOTER")
pages = filter_by_url_substring(pages, "/team")

save_to_csv(pages, "pages.csv")
save_to_json(pages, "pages.json")
save_to_sqlite(pages, "pages.sqlite")

edges = extract_link_graph(pages)
for stat in map(compute_text_stats, pages):
    print(stat)

📚 Function Documentation

remove_boilerplate_prefix(pages, delimiter)

Removes everything before and including the first occurrence of the given delimiter in text_content for each page.

  • pages: list of PageData-like objects
  • delimiter: string to match and cut before
  • Returns: cleaned list of modified objects

remove_boilerplate_suffix(pages, delimiter)

Removes everything after and including the first occurrence of the delimiter in text_content.

  • pages: list of PageData-like objects
  • delimiter: string to cut after
  • Returns: cleaned list

remove_duplicate_pages(pages)

Eliminates duplicates based on exact text_content. Keeps the first appearance.

  • Returns: list with duplicates removed

filter_by_url_substring(pages, substring)

Keeps only pages whose url contains the given substring.

  • substring: required URL fragment to retain
  • Returns: filtered list of pages

extract_link_graph(pages, include_external_links=False, only_include_crawled_pages=False)

Returns a list of (source_url, destination_url) pairs based on the internal_links field.

  • include_external_links: if False, skip links to other domains
  • only_include_crawled_pages: if True, limit to known pages only
  • Returns: list of directed edges

compute_text_stats(page)

Calculates basic content metrics:

  • word_count: total words in text_content
  • sentence_count: count of ., !, ?
  • unique_word_ratio: unique words / total words
  • link_density: words inside <a> tags / total words

Returns: dictionary with all metrics
Requires: beautifulsoup4


save_to_csv(pages, filepath, mode="w")

Writes selected fields to a .csv file.

  • filepath: output path
  • mode: "w" for overwrite, "a" for append
  • Fields: url, domain, timestamp, text_content, etc.

save_to_json(pages, filepath, mode="w")

Saves all pages as a list of dictionaries to a .json file.

  • mode: "w" or "a" (appends if file exists and is valid)

save_to_sqlite(pages, db_path, table_name="pages", append=True)

Saves all records to a local SQLite database.

  • db_path: file path for .sqlite
  • append: if False, drops and recreates table
  • table_name: optional table name override

🔧 Requirements

  • Python 3.7+
  • desync_search
  • beautifulsoup4 (for text stat parsing)

Install with:

pip install desync-data

🧑‍💻 Author

Created by Jackson Ballow for fast and scalable web content processing using Desync.


📄 License

MIT License

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

desync_data-0.1.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

desync_data-0.1.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file desync_data-0.1.3.tar.gz.

File metadata

  • Download URL: desync_data-0.1.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for desync_data-0.1.3.tar.gz
Algorithm Hash digest
SHA256 22bc5ed332a473c5da1c9199f6e7bb85d5b4f7b524363f949faed49692641924
MD5 d50f7eadd4949246e40fd400b43e7ab2
BLAKE2b-256 ea22a1de4ab9531ddeccf148e6947258ef128b5725cdb75e7972bd04025843a8

See more details on using hashes here.

File details

Details for the file desync_data-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: desync_data-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for desync_data-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ffc727d8c5dd747280c5e20a6b0a120d9d3a638b515a67eea0a2dbcc388750c3
MD5 25686892b6e8def152944a3b4f486d5f
BLAKE2b-256 76e4acd921b2878d984851550c67cda57836f5f690c024b24eb83a775022bff8

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