Method: OpenGraph.parse
- Defined in:
- lib/opengraph.rb
.parse(html, strict = true) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/opengraph.rb', line 18 def self.parse(html, strict = true) doc = Nokogiri::HTML.parse(html) page = OpenGraph::Object.new doc.css('meta').each do |m| if m.attribute('property') && m.attribute('property').to_s.match(/^og:(.+)$/i) page[$1.gsub('-','_')] = m.attribute('content').to_s end end return false if page.keys.empty? return false unless page.valid? if strict page end |