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, video_id) ⇒ Object private
- #extract_likes_from(html) ⇒ Object private
- #extract_shares_from(html, video_id) ⇒ Object private
- #extract_views_from(html) ⇒ Object private
- #parse(html:, video_id:) ⇒ Object private
Instance Method Details
#extract_comments_from(html, video_id) ⇒ 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.
40 41 42 43 44 45 46 47 |
# File 'lib/funky/html/parser.rb', line 40 def extract_comments_from(html, video_id) html.match /"commentcount":(.*?),/ html.match(/commentcount:(\d+),commentcountreduced/) if $1.nil? html.match /commentcount:(\d+),commentTotalCount/ if $1.nil? html.match /commentcount:(\d+),.*commentstargetfbid:"#{video_id}"/ if $1.nil? html.match(/comment_count:{total_count:(\d+)}/) if $1.nil? 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.
32 33 34 35 36 37 38 |
# File 'lib/funky/html/parser.rb', line 32 def extract_likes_from(html) html.match(/"likecount":(\d+),"likecountreduced"/) html.match(/likecount:(\d+),likecountreduced/) if $1.nil? html.match(%r[{localized_name:"Like",reaction_type:"LIKE",id:"1635855486666999",key:1},reaction_count:(\d+)}]) if $1.nil? html.match(%r[{reaction_count:(\d+),node:{key:1,id:"1635855486666999",localized_name:"Like",reaction_type:"LIKE"}]) if $1.nil? matched_count $1 end |
#extract_shares_from(html, video_id) ⇒ 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 18 19 20 |
# File 'lib/funky/html/parser.rb', line 14 def extract_shares_from(html, video_id) html.match(/"sharecount":(.*?),/) html.match(/sharecount:(\d+),sharecountreduced/) if $1.nil? html.match(/sharecount:(\d+),.*sharefbid:"#{video_id}"/) if $1.nil? html.match(/share_count:{count:(\d+)}/) if $1.nil? 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.
22 23 24 25 26 27 28 29 30 |
# File 'lib/funky/html/parser.rb', line 22 def extract_views_from(html) html.match(/<div><\/div><span class="fcg">\D*([\d,.]+)/) html.match(/postViewCount:"([\d,.]*?)",/) if $1.nil? html.match %r{([\d,.]*?) views from this post} if $1.nil? html.match /<div class=\"_1vx9\"><span>([\d,.]*?) .*?<\/span><\/div>/ if $1.nil? html.match /id=\"u_0_w\">([\d,.]*?) .*?<\/span><\/div>/ if $1.nil? html.match />([\d,.]*?) Views<\/span><\/div>/ if $1.nil? matched_count $1 end |
#parse(html:, video_id:) ⇒ 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:, video_id:) { view_count: extract_views_from(html), share_count: extract_shares_from(html, video_id), like_count: extract_likes_from(html), comment_count: extract_comments_from(html, video_id) } end |