Class: JohnStamos::ExtractionHelper
- Inherits:
-
Object
- Object
- JohnStamos::ExtractionHelper
- Defined in:
- lib/john_stamos/extraction_helper.rb
Class Method Summary collapse
Class Method Details
.embedded_page_json(page_content) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/john_stamos/extraction_helper.rb', line 2 def self.(page_content) seed_json_identifier = 'P.start.start' = page_content.search('script').select do |script| script['src'].nil? && script.content.include?(seed_json_identifier) end = .last.content # This regex used in the range snatches the parameter Pinterest uses to # start their app... This parameter happens to be a JSON representation of # the page. raw_json = [/#{seed_json_identifier}\((.*)\);/m, 1] JSON.parse(raw_json) end |