Zigfreid
Zigfreid

Reputation: 121

How to retrieve meta data for share from Wikipedia?

There is an Open Graph Meta Tag to share via SNS. I know that Open Graph is usually used for sharing. But, I can not find Open Graph Meta Tag from Wikipedia articles. But, I tried to share Wikipedia Article from Google Plus and Facebook, It shows very well just like using Open Graph Meta Tags.

Could you tell me how to retrieve meta data from Wikipedia articles? Is there a special method for Wikipedia?

Upvotes: 1

Views: 390

Answers (1)

FeRD
FeRD

Reputation: 2104

Wikipedia articles do not currently contain any Open Graph tags. It's therefore safe to assume that the information embedded in a Facebook share of a Wikipedia page (for example) is collected the old-fashioned way, the way Facebook has been doing it since before they published Open Graph in an effort to improve the process: By parsing it out of the page source.

While it's not as streamlined and structured as with Open Graph, parsed shares are manageable since there isn't really all that much [meta]data that goes into a "legacy" Facebook share. The Title is taken directly from the HTML <TITLE> entity, the source/author/publisher is the site hostname, and then best-guess efforts are made to identify body text for the snippet, and the image (or images, as they sometimes capture several candidates for the sharer to choose among) to use as the share thumbnail.

It usually works well enough, as you observe — generated HTML is predictable — but not always, especially (in the case of Wikipedia) where images are concerned. As an example, this is how the Wikipedia "Uranus" article appears in a Facebook share:

enter image description here

There's a photo of the planet in the article's Infobox, but that's a deeply-buried (from an HTML source perspective), right-aligned element that Facebook's parser frequently misses. And since Wikipedia's content is overwhelmingly prose-centric, many other articles contain no images at all. Facebook's parser often uses a left-aligned illustration from somewhere in the article body (as happened here), or even one of the Wikimedia Project icons in the page footer, as the "thumbnail" on Wikipedia shares.

Upvotes: 1

Related Questions