Skip to content

Instantly share code, notes, and snippets.

@endel
Last active November 7, 2015 16:18
Show Gist options
  • Save endel/272ec6cec0b877a0d5c6 to your computer and use it in GitHub Desktop.
Save endel/272ec6cec0b877a0d5c6 to your computer and use it in GitHub Desktop.
Simplest way to extract OpenGraph tags from HTML in Ruby
html = Faraday.get("http://ogp.me").body
if (data = html.scan(/property=["|']og:(.*)["|'].*content=["|'](.*)["|']/))
og = OpenStruct.new(Hash[ data ])
puts og.inspect
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment