View Source z_url_metadata (zotonic_stdlib v1.26.1)
Discover metadata about an url. Follows redirects and URL shorteners, and then fetches the data at the final URL to inspect for metadata tags, content headers and the first part of the HTML.
The returned opaque metadata can be questioned for properties using p/2.
The Slackbot user-agent is used for fetching URLs so that the URL shorteners return a location header and other sites are coerced to give correct metadata.
Only the first MB of data is fetched, this prevents fetching large objects.
Summary
Types
-type property() :: mime | mime_options | site_name | content_length | url | canonical_url | short_url | final_url | headers | title | h1 | summary | tags | filename | mtitle | description | keywords | author | charset | language | image | image_nav | thumbnail | icon | icon_nav | icon_shortcut | icon_touch | binary().
Functions
Fetch metadata information for the URL
-spec fetch(binary() | string(), z_url_fetch:options()) -> {ok, metadata()} | {error, term()}.
-spec p(Property, Metadata) -> Value when Property :: property() | [property()], Metadata :: metadata(), Value :: binary() | [binary()] | Headers | undefined, Headers :: [{binary(), binary()}].
Fetch properties of the fetched metadata