insta_scraper 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8b131720759ad9b5f4cb66fca99044afaf23f50
4
- data.tar.gz: 043f915bc0f5602f9a94255b676cd64783888c91
3
+ metadata.gz: 108e3e6f6e74ae178e1388e7725a54530ec59209
4
+ data.tar.gz: 7ccc6fd5109681adf95e815eda57c444c37ed5fd
5
5
  SHA512:
6
- metadata.gz: 49231605bbcef6f43f2887c49b982336afd52a12aa4b198399fc4f411618907858d5ccde0cb7253b101e96ed0232d1a925724ee68a9d0f7d66c9c021f2caaf79
7
- data.tar.gz: e8d82685bc5c5c34a7accc7d3fb56af51ff58a2aa503616582d4f62ef3f71a4ffc1733cfc31c5c65d93b79d98ff35fa8d4a4f3ac2e02ccc9674226c4e218fc5e
6
+ metadata.gz: 6a51bcda446ffd5201d0a48edfa73f0f252e20b20c859da8e68611c8c5d645cfe2b5e91f9a5b33d8077b7e28b0886cb237114212b28dd5c4933abba2e5b46e6f
7
+ data.tar.gz: 9218d8a7ae2579a1e86e565c66f617a06e4f33104554e10a8d5d780db75cdebd99762a0232bb85b396e27479fa31df6906e35c6ef167b4087f8afb724dd536e1
data/README.md CHANGED
@@ -63,6 +63,8 @@ media.data.deep_find('comments').fetch('count') #=> 1892
63
63
 
64
64
  ```ruby
65
65
  account_media = InstaScraper::JSON::AccountMedia.new('barna.kovacs.codes')
66
+ # or with params (ex. max_id for offset)
67
+ # account_media = InstaScraper::JSON::AccountMedia.new('barna.kovacs.codes', max_id: '1261002980537663713_3072962559')
66
68
 
67
69
  account_media.data #=> #<Hashie::Mash...
68
70
  account_media.data.fetch('items') #=> [...]
@@ -1,16 +1,18 @@
1
1
  module InstaScraper
2
2
  class HTML::Account < InstaScraper::HTML
3
- attr_reader :username
3
+ attr_reader :username,
4
+ :params
4
5
 
5
- def initialize(username = nil, html = nil)
6
+ def initialize(username = nil, html = nil, params = {})
6
7
  raise ArgumentError, 'Provide a username or html string' if !username && !html
7
8
 
8
9
  @username = username
9
10
  @html = html
11
+ @params = params
10
12
  end
11
13
 
12
14
  def url
13
- "https://www.instagram.com/#{username}/"
15
+ "https://www.instagram.com/#{username}/#{serialize_params}"
14
16
  end
15
17
 
16
18
  def data
@@ -1,16 +1,18 @@
1
1
  module InstaScraper
2
2
  class HTML::Media < InstaScraper::HTML
3
- attr_reader :code
3
+ attr_reader :code,
4
+ :params
4
5
 
5
- def initialize(code = nil, html = nil)
6
+ def initialize(code = nil, html = nil, params = {})
6
7
  raise ArgumentError, 'Provide a code or html string' if !code && !html
7
8
 
8
9
  @code = code
9
10
  @html = html
11
+ @params = params
10
12
  end
11
13
 
12
14
  def url
13
- "https://www.instagram.com/p/#{code}/"
15
+ "https://www.instagram.com/p/#{code}/#{serialize_params}"
14
16
  end
15
17
 
16
18
  def data
@@ -4,14 +4,20 @@ module InstaScraper
4
4
  @html ||= get_html
5
5
  end
6
6
 
7
+ protected
8
+
9
+ def serialize_params
10
+ return '' if params.empty?
11
+
12
+ "?" + params.map {|k, v| "#{k}=#{v}"}.join('&')
13
+ end
14
+
7
15
  private
8
16
 
9
17
  def get_html
10
18
  open(url).read
11
19
  end
12
20
 
13
- private
14
-
15
21
  def line_with_data
16
22
  html.each_line.detect { |l| l[/sharedData/] }
17
23
  end
@@ -18,13 +18,5 @@ module InstaScraper
18
18
  .extend(Hashie::Extensions::DeepFetch)
19
19
  .extend(Hashie::Extensions::DeepFind)
20
20
  end
21
-
22
- private
23
-
24
- def serialize_params
25
- return '' if params.empty?
26
-
27
- "?" + params.map {|k, v| "#{k}=#{v}"}.join('&')
28
- end
29
21
  end
30
22
  end
@@ -4,6 +4,14 @@ module InstaScraper
4
4
  @raw_json ||= get_json
5
5
  end
6
6
 
7
+ protected
8
+
9
+ def serialize_params
10
+ return '' if params.empty?
11
+
12
+ "?" + params.map {|k, v| "#{k}=#{v}"}.join('&')
13
+ end
14
+
7
15
  private
8
16
 
9
17
  def get_json
@@ -1,3 +1,3 @@
1
1
  module InstaScraper
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insta_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - preciz