insta_scrape 1.1.2 → 1.1.3

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: 789745dba3f0aec6de0b2d01d9bff151cf9cf8ca
4
- data.tar.gz: ca9584f98624278aec6d4579c9f7609a5a678e51
3
+ metadata.gz: df0bc7e6b5141cf6b562799acb5cd1a779a39306
4
+ data.tar.gz: c23aca7fda329193195ef531b9949de666c6936a
5
5
  SHA512:
6
- metadata.gz: b25877f743ac994344209970a9ba2b9d3626fe7a5b1ec973b4abe69487c58ed4e5568ac27536c271a1c1e77ce1c56b8d2a938f0df0615712ea61a42c48d37916
7
- data.tar.gz: 0ecfd826b132099e6117b15a793ce09a9e7cd3ba1ff2e801466aae10be2310b5539ddd037ee9872c83166883c9c984ba09bff77a7ce2e93ae6179db7e6fc069e
6
+ metadata.gz: 1b2f7e871cb0dc8be077260c85daea7d76324af59ccdf44fbe566f29b364a1fe550f1fa95b0219163646f2900930d247a08ff22a221dc5e735a080dc8855ee94
7
+ data.tar.gz: 96da2fbf7ad431d7a116c4e3ac71bbf3e441f9be134609c8113e58001cdefb6188ce99320acb0e0fa0f3b11b019fb99087dc74c0114e7230d321e6daef3ddbd9
data/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
- *.gem
2
1
  *.rbc
3
2
  .bundle
4
3
  .config
data/README.md CHANGED
@@ -3,26 +3,14 @@
3
3
  ![alt text](https://s3-us-west-2.amazonaws.com/instascrape/instascrapelogo.png "logo")
4
4
  # InstaScrape
5
5
 
6
- A ruby scraper for instagram in 2017. Because the hashtag deprecation in the API is just silly.
7
- This gem is dependent on Capybara, PhantomJS, and Poltergeist.
6
+ The instagram swiss army knife. Restores all deprecated hashtag functionality and grants public api access from instagram's front end without any of the authorization.
8
7
 
9
- Using this gem you can access multiple facets of the instagram API without needing authorization, most importantly the hashtag.
8
+ With `include_meta_data: true`, you can return a posts image, link, text, date, username, hi_res_image, and likes.
9
+ See the examples and usage pages for different methods and how to use them.
10
10
 
11
- ```shell
12
- #UPDATES
13
- v.1.1.2 text from images is now a default part of the post object & international support bugfix
14
- v.1.1.1 introducing optional metadata!
15
- v.1.1.0 introducing "long_scrape" methods! Now with more instagram posts!
16
- ```
17
-
18
- ## Note
19
-
20
- The number of results may vary when using certain methods as this isn't an official endpoint.
21
-
22
- ## Todo
23
-
24
- * Built-in Pagination
11
+ #### Note [ *PLEASE READ* ]
25
12
 
13
+ The number of results may vary when using certain methods as this *IS NOT* an official endpoint.
26
14
 
27
15
  ## Installation
28
16
 
@@ -32,6 +20,12 @@ Add this line to your application's Gemfile:
32
20
  gem "insta_scrape"
33
21
  ```
34
22
 
23
+ For bleeding edge, install from the development branch:
24
+
25
+ ```ruby
26
+ gem "insta_scrape", :git => "https://github.com/dannyvassallo/insta_scrape.git", :branch => "develop"
27
+ ```
28
+
35
29
  And then execute:
36
30
 
37
31
  $ bundle
@@ -40,77 +34,14 @@ Or install it yourself as:
40
34
 
41
35
  $ gem install insta_scrape
42
36
 
43
- ## Usage
44
-
45
- ###Available methods
46
-
47
- Long scrape method take two arguments -- (hashtag || username, time_in_seconds)
48
- Each other method accepts only one argument - a hashtag or a username.
49
-
50
- An additional feature has been added to grab some extra meta information (dates) from the posts.
51
- While this feature makes the scrape perform much slower, you can opt in to using it with
52
- the following option as a second or third argument on most methods:
37
+ ## How To Use
53
38
 
54
- `include_meta_data: true`
55
-
56
- For Example:
57
-
58
- ```ruby
59
- InstaScrape.hashtag("foofighters", include_meta_data: true)
60
-
61
- #OR
62
-
63
- InstaScrape.long_scrape_hashtag("foofighters", 30, include_meta_data: true)
64
- ```
65
-
66
- If you run the methods regularly, you won't get additional meta information.
67
-
68
- ####Long Scrape Methods
69
- ```ruby
70
- #These can take a while but produce the best results
71
- #I would recommend running a background job to pull these scrapes
72
-
73
- #long scrape a user and their posts
74
- #depending on how long you run the scrape
75
- #you can pull an entire user profile and all of their posts
76
- #30 seconds is enough for a casual user (maybe less)
77
- InstaScrape.long_scrape_user_info_and_posts('foofighters', 30)
78
- #this does the same without pulling user info
79
- InstaScrape.long_scrape_user_posts('foofighters', 30)
80
-
81
- #pull all posts from a hashtag
82
- #infinite scroll will run as long as the time passed in
83
- InstaScrape.long_scrape_hashtag('test', 60)
84
- #=> > 2k instagram posts! Tested in specs!
85
- ```
86
-
87
- ####Regular Methods
88
- ```ruby
89
- #scrape a hashtag for as many results as possible
90
- InstaScrape.hashtag("test")
91
- #scrape all user info
92
- InstaScrape.user_info("foofighters")
93
- #scrape all user info and posts
94
- InstaScrape.user_info_and_posts("foofighters")
95
- #scrape just a users posts (as many as possible)
96
- InstaScrape.user_posts("foofighters")
97
- #scrape a users follower count
98
- InstaScrape.user_follower_count("foofighters")
99
- #scrape a users following count
100
- InstaScrape.user_following_count("foofighters")
101
- #scrape a users post count
102
- InstaScrape.user_post_count("foofighters")
103
- #scrape a users description
104
- InstaScrape.user_description("foofighters")
105
- ```
39
+ You'll probably want to use the [whenever](https://github.com/javan/whenever) gem or something similar in order to create hashtag widgets like you once could. Scheduling a job (polling) and storing each post's information in your database/cache is one way to do it.
106
40
 
107
- ####Hashtag, User Post, and Nested Posts Scrape
108
41
 
42
+ Standard Hashtag Scrape Example:
109
43
  ```ruby
110
44
  #basic use case
111
-
112
- #scrape_result = InstaScrape.user_info_and_posts("foofighters").posts
113
- #scrape_result = InstaScrape.user_posts("foofighters")
114
45
  scrape_result = InstaScrape.hashtag("test")
115
46
  scrape_result.each do |post|
116
47
  puts post.image
@@ -119,80 +50,31 @@ scrape_result.each do |post|
119
50
  end
120
51
  ```
121
52
 
122
- Here is a `.erb` example using MaterializeCSS to render the posts as cards:
123
-
124
- ```ruby
125
- #in your controller or helper assuming you aren't storing the posts
126
-
127
- #@posts = InstaScrape.user_info_and_posts("foofighters").posts
128
- #@posts = InstaScrape.user_posts("foofighters")
129
- @posts = InstaScrape.hashtag("test")
130
- ```
131
-
132
- ```ruby
133
- # your .erb file
134
- # access post attributes using dot notation
135
- <div class="row">
136
- <% @posts.each do |post| %>
137
- <div class="col s12 m6 l4">
138
- <div class="card hoverable">
139
- <div class="card-image"><a href="<%= post.link %>"><img src="<%= post.image %>"></a></div>
140
- <div class="card-content">
141
- <!-- <p></p> -->
142
- </div>
143
- <div class="card-action center-align"><a class="btn black" href="<%= post.link %>">Open Post</a></div>
144
- </div>
145
- </div>
146
- <% end %>
147
- </div>
148
- ```
149
-
150
- ####User Info
151
-
152
- All user information is accessible using dot notation.
153
- If we run:
154
- ```ruby
155
- u = InstaScrape.user_info("foofighters")
156
- ```
157
- We then have access to the following attributes:
53
+ Long Scrape a hashtag and get additional metadata:
158
54
  ```ruby
159
- u.image
160
- #returns => "https://instagram.fewr1-2.fna.fbcdn.net/t51.2885-19/11856782_370180896524950_961003442_a.jpg"
161
- u.post_count
162
- #returns => "305"
163
- u.follower_count
164
- #returns => "1.5m"
165
- u.following_count
166
- #returns => "35"
167
- u.description
168
- #returns => "Foo Fighters Rock band smarturl.it/sonic-highways"
169
-
170
- #and in the event you'd need it
171
- u.username
172
- #returns => "foofighters"
55
+ #you can set include_meta_data to false if
56
+ #you want to speed up the scrape
57
+ scrape_result = InstaScrape.long_scrape_hashtag('test', 1, include_meta_data: true)
58
+ scrape_result.each do |post|
59
+ puts post.image
60
+ puts post.link
61
+ puts post.text
62
+ puts post.date
63
+ puts post.username
64
+ puts post.hi_res_image
65
+ puts post.likes
66
+ end
173
67
  ```
174
68
 
175
- Each of these attributes is accessible using the methods listed above as well.
69
+ ### See the InstaScrape Wiki [HERE](https://github.com/dannyvassallo/insta_scrape/wiki/) to learn the rest of InstaScrape's features.
176
70
 
177
- Using `u = InstaScrape.user_info_and_posts("foofighters")` will give access to the `u.posts` attribute and can be iterated through.
178
- The example above covers this.
71
+ ## Problems? Need Help?
179
72
 
180
- ## Development
181
-
182
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
183
-
184
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
185
-
186
- ## Deployment / Build
187
-
188
- ```
189
- gem build insta_scrape.gemspec
190
- gem push insta_scrape-v.v.v.gem
191
- ```
73
+ Create an [issue](https://github.com/dannyvassallo/insta_scrape/issues) and I'll respond as soon as I can. If it's a feature request and you've got some free time -- PRs are gladly welcomed.
192
74
 
193
75
  ## Contributing
194
76
 
195
- Bug reports and pull requests are welcome on GitHub at https://github.com/dannyvassallo/insta_scrape. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
77
+ ❗️[*Bug reports and pull requests are ALWAYS welcome on GitHub*](https://github.com/dannyvassallo/insta_scrape)❗️. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
196
78
 
197
79
 
198
80
  ## License
Binary file
Binary file
Binary file
Binary file
Binary file
data/insta_scrape.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["dannyvassallo"]
10
10
  spec.email = ["danielvassallo87@gmail.com"]
11
11
 
12
- spec.summary = %q{Use Instagram Hashtag Embeds in 2016}
13
- spec.description = %q{A ruby scraper for instagram in 2016. Because the hashtag deprecation in the API is just silly. This gem is dependent on Capybara, PhantomJS, and Poltergeist. v.1.1.0 -- Introducing long_scrape methods! Get thousands of photo results on hashtags and full user profiles with ALL posts! See the documentation for API usage.}
12
+ spec.summary = %q{Use Instagram Hashtag API in 2017}
13
+ spec.description = %q{The swiss army knife of instagram functionality. Restores all deprecated hashtag functionality from the instagram api without any of the authorization.}
14
14
  spec.homepage = "https://github.com/dannyvassallo/insta_scrape"
15
15
  spec.license = "MIT"
16
16
 
@@ -1,5 +1,5 @@
1
1
  Capybara.register_driver :poltergeist do |app|
2
- driver = Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
2
+ driver = Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path, :js_errors => false)
3
3
  driver.add_header('Accept-Language', 'en')
4
4
  driver
5
5
  end
data/lib/insta_scrape.rb CHANGED
@@ -84,11 +84,20 @@ module InstaScrape
84
84
 
85
85
  posts.each do |post|
86
86
  if include_meta_data
87
- visit(post[:link])
87
+ visit(post[:link])
88
88
  date = page.find('time')["datetime"]
89
- info = InstaScrape::InstagramPost.new(post[:link], post[:image], date, text)
89
+ username = page.first("article header div a")["title"]
90
+ hi_res_image = page.all("img").last["src"]
91
+ likes = page.find("div section span span")["innerHTML"]
92
+ info = InstaScrape::InstagramPost.new(post[:link], post[:image], {
93
+ date: date,
94
+ text: text,
95
+ username: username,
96
+ hi_res_image: hi_res_image,
97
+ likes: likes
98
+ })
90
99
  else
91
- info = InstaScrape::InstagramPost.new(post[:link], post[:image], text)
100
+ info = InstaScrape::InstagramPost.new(post[:link], post[:image], { text: text })
92
101
  end
93
102
  @posts << info
94
103
  end
@@ -176,10 +185,17 @@ module InstaScrape
176
185
 
177
186
  #post logger
178
187
  def self.log_posts
179
- @posts.each do |post|
180
- puts "\n"
181
- puts "Image: #{post.image}\n"
182
- puts "Link: #{post.link}\n"
188
+ post = @posts.sample
189
+ puts "* Printing Sample Post *"
190
+ puts "\n"
191
+ puts "Image: #{post.image}\n"
192
+ puts "Link: #{post.link}\n"
193
+ puts "Text: #{post.text}\n"
194
+ if post.date
195
+ puts "Date: #{post.date}\n"
196
+ puts "Username: #{post.username}\n"
197
+ puts "Hi Res Image: #{post.hi_res_image}\n"
198
+ puts "Likes: #{post.likes}\n"
183
199
  end
184
200
  puts "\n"
185
201
  end
@@ -1,3 +1,3 @@
1
1
  module InstaScrape
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -1,9 +1,12 @@
1
1
  class InstaScrape::InstagramPost
2
- attr_accessor :link, :image, :date, :text
3
- def initialize(link, image, date=nil, text=nil)
2
+ attr_accessor :link, :image, :date, :text, :username, :hi_res_image, :likes
3
+ def initialize(link, image, options = {})
4
4
  @image = image
5
5
  @link = link
6
- @date = date
7
- @text = text
6
+ @date = options[:date]
7
+ @text = options[:text]
8
+ @username = options[:username]
9
+ @hi_res_image = options[:hi_res_image]
10
+ @likes = options[:likes]
8
11
  end
9
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insta_scrape
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dannyvassallo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-26 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -172,10 +172,8 @@ dependencies:
172
172
  - - ">="
173
173
  - !ruby/object:Gem::Version
174
174
  version: 1.9.0
175
- description: A ruby scraper for instagram in 2016. Because the hashtag deprecation
176
- in the API is just silly. This gem is dependent on Capybara, PhantomJS, and Poltergeist.
177
- v.1.1.0 -- Introducing long_scrape methods! Get thousands of photo results on hashtags
178
- and full user profiles with ALL posts! See the documentation for API usage.
175
+ description: The swiss army knife of instagram functionality. Restores all deprecated
176
+ hashtag functionality from the instagram api without any of the authorization.
179
177
  email:
180
178
  - danielvassallo87@gmail.com
181
179
  executables: []
@@ -192,6 +190,11 @@ files:
192
190
  - Rakefile
193
191
  - bin/console
194
192
  - bin/setup
193
+ - insta_scrape-0.1.0.gem
194
+ - insta_scrape-1.0.0.gem
195
+ - insta_scrape-1.1.0.gem
196
+ - insta_scrape-1.1.1.gem
197
+ - insta_scrape-1.1.2.gem
195
198
  - insta_scrape.gemspec
196
199
  - lib/dependencies.rb
197
200
  - lib/init/poltergeist.rb
@@ -223,5 +226,5 @@ rubyforge_project:
223
226
  rubygems_version: 2.5.1
224
227
  signing_key:
225
228
  specification_version: 4
226
- summary: Use Instagram Hashtag Embeds in 2016
229
+ summary: Use Instagram Hashtag API in 2017
227
230
  test_files: []