Class: TradingviewScreener::ScreenData::Parser
- Inherits:
-
Object
- Object
- TradingviewScreener::ScreenData::Parser
- Defined in:
- lib/tradingview_screener/screen_data.rb
Constant Summary collapse
- SCREEN_DATA_RE =
/window\.initData\.screen_data\s*=\s*(\{.*?\})\s*;\s*\n\s*window\.initData\.onScreenerStandalonePage/m
Class Method Summary collapse
Class Method Details
.extract_screen_data(html) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/tradingview_screener/screen_data.rb', line 35 def self.extract_screen_data(html) text = html.to_s match = text.match(SCREEN_DATA_RE) raise ParseError, "screen_data not found in HTML" unless match JSON.parse(match[1]) rescue JSON::ParserError => e raise ParseError, "invalid screen_data JSON: #{e.}" end |