followers_number 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73d7619b12e30e16394c86dd9844092c8f677360f9d39e85796241dd31dcf36d
4
- data.tar.gz: fce06805d58f83f19a0d9b4f3a8c75e022b67cf93220ce2375969c704032e827
3
+ metadata.gz: 420049d0bc7d33ee524611b6bde310aed680d73846fbd16e3130de3d66bc808a
4
+ data.tar.gz: 3493baaf531d026a22fb278eac4c5256fa51e2114d594c693b3acb4d76d3ccaa
5
5
  SHA512:
6
- metadata.gz: d05b513038c3a3f58fa445cb0c2439b45ba01af7199204c04faa0196f89d6c54aa8c739380b29f5d659693a1c6980398ec048b204a487e3472d8eb8a5cec5760
7
- data.tar.gz: bd65b81adf091b3ff3c41ce32b365d241a64d3f2f91545f4fd81676c3a0f5ff17c75d74b734600e116778dde60cd6b03243ecfb7befa299dc588510875ed4aba
6
+ metadata.gz: 5caee59e56e489edc7f5dbd703e256e236234e45b3eaed3cd4e7db8ebdb97bfd50bbb4b834a92541d758d8232140c2814dcb3a45f83c52a611587deb5da96d98
7
+ data.tar.gz: 2047e6b916f124c45426696ec20cdc408e87a727512754f03579c8446ba8755cc09a66a972fb48ed8dd3a555f9826a289d816a88d2d2dcbad63de378549da6ce
@@ -1,7 +1,8 @@
1
1
  module FollowersNumber
2
2
  class Parser
3
3
  MAPPING = {
4
- 'twitter.com' => FollowersNumber::Parsers::Twitter
4
+ 'twitter.com' => FollowersNumber::Parsers::Twitter,
5
+ 'instagram.com' => FollowersNumber::Parsers::Instagram
5
6
  }
6
7
 
7
8
  def self.call(profile_url, response)
@@ -0,0 +1,11 @@
1
+ module FollowersNumber
2
+ module Parsers
3
+ class Instagram
4
+ def self.parse(html)
5
+ raw_json = html.to_s.match(/window\._sharedData =.*(?=;)/)
6
+ json = JSON.parse(raw_json.to_s.gsub("window._sharedData = ", ""))
7
+ json["entry_data"]["ProfilePage"].first["graphql"]["user"]["edge_followed_by"]["count"]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,7 +2,7 @@ module FollowersNumber
2
2
  class Validator
3
3
  class InvalidProfileURL < StandardError; end
4
4
 
5
- NETWORKS = %w[twitter.com]
5
+ NETWORKS = %w[twitter.com instagram.com]
6
6
 
7
7
  def self.validate!(profile_url)
8
8
  unless NETWORKS.include?(URI.parse(profile_url.to_s.downcase).host)
@@ -6,7 +6,7 @@ module FollowersNumber
6
6
  #
7
7
  # @return [String]
8
8
  def to_s
9
- "0.0.1"
9
+ "0.0.2"
10
10
  end
11
11
  end
12
12
  end
@@ -1,4 +1,6 @@
1
1
  require_relative 'followers_number/parsers/twitter'
2
+ require_relative 'followers_number/parsers/instagram'
3
+
2
4
  require_relative 'followers_number/request'
3
5
  require_relative 'followers_number/validator'
4
6
  require_relative 'followers_number/parser'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: followers_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski
@@ -66,6 +66,7 @@ extra_rdoc_files: []
66
66
  files:
67
67
  - lib/followers_number.rb
68
68
  - lib/followers_number/parser.rb
69
+ - lib/followers_number/parsers/instagram.rb
69
70
  - lib/followers_number/parsers/twitter.rb
70
71
  - lib/followers_number/request.rb
71
72
  - lib/followers_number/validator.rb