Skip to main content

av-ld_json_extractor

A lightweight Python library designed to extract ld+json from <script> tags within HTML documents

Installation

Using uv:

uv add av-ld_json_extractor

Quick Start

1. Extract JSON-LD Data from HTML

from selectolax.lexbor import LexborHTMLParser
from av_ld_json_extractor import ld_json_iter

html_content = """
<!DOCTYPE html>
<html>
<head>
    <script type="application/ld+json">
        {"@context": "[https://schema.org](https://schema.org)", "@type": "Organization", "name": "Example Corp"}
    </script>
    <script type="application/ld+json">
        {"@type": "Product", "name": "Gaming Laptop", "price": 1200}
    </script>
</head>
</html>
"""

parser = LexborHTMLParser(html_content)

for data in ld_json_iter(parser):
    print(data)
# Output:
# {'@context': '[https://schema.org](https://schema.org)', '@type': 'Organization', 'name': 'Example Corp'}
# {'@type': 'Product', 'name': 'Gaming Laptop', 'price': 1200}

2. Find Specific @type (Objects & Lists)

from selectolax.lexbor import LexborHTMLParser
from av_ld_json_extractor import find_ld_json

html_content = """
<script type="application/ld+json">
    [
        {"@type": "BreadcrumbList", "itemListElement": []},
        {"@type": "Product", "name": "Wireless Mouse", "price": 25}
    ]
</script>
"""

parser = LexborHTMLParser(html_content)

# Automatically searches inside both single JSON objects and array lists
product = find_ld_json("Product", parser)
print(product)
# Output:
# {'@type': 'Product', 'name': 'Wireless Mouse', 'price': 25}

Download files

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

Source Distribution

ld_json_extractor-0.1.5.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

ld_json_extractor-0.1.5-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file ld_json_extractor-0.1.5.tar.gz.

File metadata

  • Download URL: ld_json_extractor-0.1.5.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.21

File hashes

Hashes for ld_json_extractor-0.1.5.tar.gz
Algorithm Hash digest
SHA256 24e9ed8dbe21485cc1286181f6bb7c32eca84314b59eba12660bf02e8666dbce
MD5 6507ce128a6a81f5f3841d3e851fe98f
BLAKE2b-256 31049c9c0ae01e3887fcdfb9bc3e914b5c6c476f21b6524c0eeeaf50d7592620

See more details on using hashes here.

File details

Details for the file ld_json_extractor-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for ld_json_extractor-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4fc3fc41c120b439c76a0c5acaa350286198b8e44be1fc1938fbcf80abd4841b
MD5 c67390f58570ed11b4ee9d00b4d826dc
BLAKE2b-256 4537c214501e33cce22fb2ada7346d20f2e7e70011a152028cc30e80e133dd79

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page