Skip to content

Commit

Permalink
Capture view count while being language agnostic
Browse files Browse the repository at this point in the history
Before we depended the capture on the view count located between
`<span class="fcg">` and `Views`. Obviously, `Views` is English,
making it language dependent. So we changed the regex to look for
numbers after `<span class="fcg">` instead, which should be
language agnostic for the most part.
  • Loading branch information
philipqnguyen committed Jun 22, 2016
1 parent e421f8f commit 35a219c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/funky/html/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extract_shares_from(html)
end

def extract_views_from(html)
html.match(/<div><\/div><span class="fcg">(.*) Views<\/span>/)
html.match(/<div><\/div><span class="fcg">\D*([,0-9]+)/)
html.match %r{([\d,]*?) views from this post} if $1.nil?
matched_count $1
end
Expand Down

0 comments on commit 35a219c

Please sign in to comment.