followers_number 0.0.4 → 0.0.5

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: 9a91655cedea38e7fbb2c0a3e2c82b4b38156cf7a12c105dded623602e2c1066
4
- data.tar.gz: ce848866f2547f355e3ff4816fb4256d329510c013f1194b50bed196bc77854f
3
+ metadata.gz: 0b245a9fe94280efa09b8247bea217416d42b920f15e623601314f277f0f35a8
4
+ data.tar.gz: 16288ef59f639f89e2cbe93a77e1a8d8bddbcba042b4d1bfdc918ec9efcf1c9c
5
5
  SHA512:
6
- metadata.gz: 89151c60a7cf5b6b4ea22078622d91814ce9e225f4d0a1e06b364eb12e4a7575beb53acba2015d8d92c88c77f8cade7b8874143e08824a741269c4468e9d8119
7
- data.tar.gz: 80510d79d2ac4db3a065671ab5fc0cd4d883af39a767af7f787b9d9954bcd1881544e7996636e0af790a368c5379b8c773c0ba8cd5c05d420f253a4a8bab63db
6
+ metadata.gz: 08a74883b21741cb5fb7797a63c9ed4d24a5bf73fdb8d4f1713bab08e27b8a175455824913ccbd766941b813b447889b983be35bdd1c4e0be3bf5db9a463752c
7
+ data.tar.gz: 329230437d1c176ea00af24ce0adb5ae1bd282a0a3512deb52384133ec07bbf80a32ad9a8fc23d074517cc0104357563f97abb505ea8bffbd2acb4820138b90b
@@ -3,7 +3,8 @@ module FollowersNumber
3
3
  MAPPING = {
4
4
  'twitter.com' => FollowersNumber::Parsers::Twitter,
5
5
  'instagram.com' => FollowersNumber::Parsers::Instagram,
6
- 'youtube.com' => FollowersNumber::Parsers::Youtube
6
+ 'youtube.com' => FollowersNumber::Parsers::Youtube,
7
+ 'facebook.com' => FollowersNumber::Parsers::Facebook
7
8
  }
8
9
 
9
10
  def self.call(profile_url, response)
@@ -0,0 +1,9 @@
1
+ module FollowersNumber
2
+ module Parsers
3
+ class Facebook
4
+ def self.parse(html)
5
+ html.css("div._3xom").first.text.to_i
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,14 @@
1
1
  module FollowersNumber
2
2
  class Request
3
3
  def self.get(profile_url)
4
- ::RestClient.get(profile_url)
4
+ headers = {
5
+ "Content-Language" => "en-US",
6
+ "Accept-Language" => "en-US",
7
+ "user-agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36",
8
+ "Cookie" => ""
9
+ }
10
+
11
+ ::RestClient::Request.execute(method: :get, url: profile_url, headers: headers)
5
12
  end
6
13
  end
7
14
  end
@@ -2,7 +2,7 @@ module FollowersNumber
2
2
  class Validator
3
3
  class InvalidProfileURL < StandardError; end
4
4
 
5
- NETWORKS = %w[twitter.com instagram.com youtube.com]
5
+ NETWORKS = %w[twitter.com instagram.com youtube.com facebook.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.4"
9
+ "0.0.5"
10
10
  end
11
11
  end
12
12
  end
@@ -5,6 +5,7 @@ require 'json'
5
5
  require_relative 'followers_number/parsers/twitter'
6
6
  require_relative 'followers_number/parsers/instagram'
7
7
  require_relative 'followers_number/parsers/youtube'
8
+ require_relative 'followers_number/parsers/facebook'
8
9
 
9
10
  require_relative 'followers_number/request'
10
11
  require_relative 'followers_number/validator'
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.4
4
+ version: 0.0.5
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/facebook.rb
69
70
  - lib/followers_number/parsers/instagram.rb
70
71
  - lib/followers_number/parsers/twitter.rb
71
72
  - lib/followers_number/parsers/youtube.rb