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 +4 -4
- data/README.md +2 -0
- data/lib/insta_scraper/html/account.rb +5 -3
- data/lib/insta_scraper/html/media.rb +5 -3
- data/lib/insta_scraper/html.rb +8 -2
- data/lib/insta_scraper/json/account_media.rb +0 -8
- data/lib/insta_scraper/json.rb +8 -0
- data/lib/insta_scraper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 108e3e6f6e74ae178e1388e7725a54530ec59209
|
4
|
+
data.tar.gz: 7ccc6fd5109681adf95e815eda57c444c37ed5fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/insta_scraper/html.rb
CHANGED
@@ -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
|
data/lib/insta_scraper/json.rb
CHANGED