Class: Funky::HTML::Parser Private
- Inherits:
-
Object
- Object
- Funky::HTML::Parser
- Defined in:
- lib/funky/html/parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #extract_comments_from(html) ⇒ Object private
- #extract_likes_from(html) ⇒ Object private
- #extract_shares_from(html) ⇒ Object private
- #extract_views_from(html) ⇒ Object private
- #parse(html:) ⇒ Object private
Instance Method Details
#extract_comments_from(html) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 33 |
# File 'lib/funky/html/parser.rb', line 30 def extract_comments_from(html) html.match /"commentcount":(.*?),/ matched_count $1 end |
#extract_likes_from(html) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 |
# File 'lib/funky/html/parser.rb', line 25 def extract_likes_from(html) html.match /"likecount":(.*?),/ matched_count $1 end |
#extract_shares_from(html) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 |
# File 'lib/funky/html/parser.rb', line 14 def extract_shares_from(html) html.match(/"sharecount":(.*?),/) matched_count $1 end |
#extract_views_from(html) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 |
# File 'lib/funky/html/parser.rb', line 19 def extract_views_from(html) html.match(/<div><\/div><span class="fcg">(.*) Views<\/span>/) html.match %r{([\d,]*?) views from this post} if $1.nil? matched_count $1 end |
#parse(html:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 8 9 10 11 12 |
# File 'lib/funky/html/parser.rb', line 5 def parse(html:) { view_count: extract_views_from(html), share_count: extract_shares_from(html), like_count: extract_likes_from(html), comment_count: extract_comments_from(html) } end |