Last active
November 7, 2015 16:18
-
-
Save endel/272ec6cec0b877a0d5c6 to your computer and use it in GitHub Desktop.
Simplest way to extract OpenGraph tags from HTML in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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