Skip to content

extruct

802 10 53 BSD
0.16.0 (7 Jul 2023) Oct 27 2015 187.8 thousand (month)

extruct is a library for extracting embedded metadata from HTML markup.

Currently, extruct supports:

  • W3C's HTML Microdata
  • embedded JSON-LD
  • Microformat via mf2py
  • Facebook's Open Graph
  • (experimental) RDFa via rdflib
  • Dublin Core Metadata (DC-HTML-2003)

Extruct is a brilliant data parser for schema.org marked up websites (many modern websites) and is an easy way to extract popular details like product information, company contact details etc.

Example Use


# retrieve HTML content
import httpx

response = httpx.get('https://webscraping.fyi/lib/python/extruct')

import extruct

all_data = extruct.extract(response.text, response.url)

# or we can extract specific metadata format by importing individuals extractors:


extractor = extruct.MicrodataExtractor()
microdata = extractor.extract(response.text)

extractor = extruct.JsonLdExtractor()
jsonld = extractor.extract(response.text) 

Alternatives / Similar


1,595 2024.2.26 (a month ago) Dec 14 2008 compare
13,656 0.2.8 (5 years ago) Dec 28 2012 compare
2,463 0.8.1 (3 years ago) Jun 30 2011 compare
2,594 1.7.0 (2 months ago) Jul 17 2019 compare
3,375 0.11.0 (1 year, 5 months ago) Oct 20 2013 compare
10,458 1.1.9 (5 years ago) Aug 24 2018 compare
157 2.0.7 (1 year, 4 months ago) Dec 11 2020 compare

Other Languages

2,400 v1.3.0 (a month ago) Apr 20 2016 compare
2,063 v4.4.10 (3 months ago) Oct 26 2013 compare