Method: Forki::UserScraper#find_number_of_followers
- Defined in:
- lib/forki/scrapers/user_scraper.rb
#find_number_of_followers(profile_details_string) ⇒ Object
Finds and returns the number of people who follow the current page
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/forki/scrapers/user_scraper.rb', line 17 def find_number_of_followers(profile_details_string) followers_pattern = /Followed by (?<num_followers>[0-9,.KM ]) people/ alt_follower_pattern = /(?<num_followers>[0-9,.KM ]+) (f|F)ollowers/ number_of_followers_match = followers_pattern.match(profile_details_string) || alt_follower_pattern.match(profile_details_string) return nil if number_of_followers_match.nil? number_of_followers = Scraper.extract_int_from_num_element(number_of_followers_match.named_captures["num_followers"]) # Note, this is sticking around if we want to use it later # if number_of_followers.nil? # number_of_followers_string = JSON.parse(profile_header_str)["user"]["profile_header_renderer"]["user"]["profile_social_context"]["content"].first["text"]["text"] # number_of_followers = Scraper.extract_int_from_num_element(number_of_followers_string) # end number_of_followers end |