metadata_extract 1.0.0
metadata_extract: ^1.0.0 copied to clipboard

A dart library for extracting metadata on web pages such as OpenGraph, Meta, Twitter Cards, and Structured Data (Json-LD)

example/main.dart

import 'package:metadata_extract/metadata_extract.dart';
import 'package:http/http.dart' as http;

class Examples {
  static Future<void> basicExtract() async {
    var data =
        await extract('https://flutter.dev'); // returns a Metadata object
    print(data); // Metadata.toString()
    print(data!.title); // Metadata.title
    print(data.toMap()); // converts Metadata to map
    print(data.toJson()); // converts Metadata to JSON
  }

  static Future<void> parseDocument() async {
    var url = 'https://flutter.dev';
    var response = await http.get(Uri.parse(url));
    var document = responseToDocument(response);

    var data = MetadataParser.parse(document);
    print(data);

    // Just Opengraph
    var og = MetadataParser.openGraph(document);
    print(og);

    var hm = MetadataParser.htmlMeta(document);
    print(hm);

    var js = MetadataParser.jsonLdSchema(document);
    print(js);

    var twitter = MetadataParser.twitterCard(document);
    print(twitter);
  }
}

void main() async {
  await Examples.basicExtract();
  await Examples.parseDocument();
}
2
likes
130
pub points
78%
popularity

Publisher

thatch.dev

A dart library for extracting metadata on web pages such as OpenGraph, Meta, Twitter Cards, and Structured Data (Json-LD)

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD (LICENSE)

Dependencies

collection, html, http, string_validator

More

Packages that depend on metadata_extract