birdsong 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/birdsong/scrapers/scraper.rb +44 -43
- data/lib/birdsong/version.rb +1 -1
- data/lib/birdsong.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91cec2f940312e308a14a0f84049908d0a38cc9ef53548c0ef9907c5c46bffeb
|
4
|
+
data.tar.gz: a7871d2629fa2eec4bb9ee73b635bf974f1ec5f7c0606070e446b6937c60fe9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b073c5546b6a4b22184809d4b1e8381bdd18b07f577f49d6c096ecded7e8b08ff546730a913cb8f41945036f9372bfb503b655eda24bdcff9ba924f9e7b81a
|
7
|
+
data.tar.gz: fa6f487b45dc2b284773d4dbccefefeacb74200b2b0f14341a187d899bc82e2048a65e50524e9577e05e0cd9f1a4f0d7f0b8bbdc37d3075a643e143aa7dc9064
|
@@ -108,6 +108,7 @@ module Birdsong
|
|
108
108
|
end
|
109
109
|
|
110
110
|
page.driver.execute_script("window.stop();")
|
111
|
+
|
111
112
|
raise Birdsong::NoTweetFoundError if response_body.nil?
|
112
113
|
Oj.load(response_body)
|
113
114
|
end
|
@@ -140,49 +141,49 @@ module Birdsong
|
|
140
141
|
Capybara.current_driver = :selenium
|
141
142
|
end
|
142
143
|
|
143
|
-
def login
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
# We don't have to login if we already are
|
156
|
-
begin
|
157
|
-
|
158
|
-
rescue Capybara::ElementNotFound; end
|
159
|
-
|
160
|
-
# Check if we're redirected to a login page, if we aren't we're already logged in
|
161
|
-
return unless page.has_xpath?('//*[@id="loginForm"]/div/div[3]/button')
|
162
|
-
|
163
|
-
# Try to log in
|
164
|
-
loop_count = 0
|
165
|
-
while loop_count < 5 do
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
end
|
177
|
-
|
178
|
-
# Sometimes Instagram just... doesn't let you log in
|
179
|
-
raise "Instagram not accessible" if loop_count == 5
|
180
|
-
|
181
|
-
# No we don't want to save our login credentials
|
182
|
-
begin
|
183
|
-
|
184
|
-
rescue Capybara::ElementNotFound; end
|
185
|
-
end
|
144
|
+
# def login
|
145
|
+
# # Reset the sessions so that there's nothing laying around
|
146
|
+
# page.quit
|
147
|
+
|
148
|
+
# # Check if we're on a Instagram page already, if not visit it.
|
149
|
+
# unless page.driver.browser.current_url.include? "twitter.com"
|
150
|
+
# # There seems to be a bug in the Linux ARM64 version of chromedriver where this will properly
|
151
|
+
# # navigate but then timeout, crashing it all up. So instead we check and raise the error when
|
152
|
+
# # that then fails again.
|
153
|
+
# page.driver.browser.navigate.to("https://twitter.com")
|
154
|
+
# end
|
155
|
+
|
156
|
+
# # We don't have to login if we already are
|
157
|
+
# begin
|
158
|
+
# return if find_field("Search", wait: 10).present?
|
159
|
+
# rescue Capybara::ElementNotFound; end
|
160
|
+
|
161
|
+
# # Check if we're redirected to a login page, if we aren't we're already logged in
|
162
|
+
# return unless page.has_xpath?('//*[@id="loginForm"]/div/div[3]/button')
|
163
|
+
|
164
|
+
# # Try to log in
|
165
|
+
# loop_count = 0
|
166
|
+
# while loop_count < 5 do
|
167
|
+
# fill_in("username", with: ENV["TWITTER_USER_NAME"])
|
168
|
+
# fill_in("password", with: ENV["TWITTER_PASSWORD"])
|
169
|
+
|
170
|
+
# begin
|
171
|
+
# click_button("Log in", exact_text: true) # Note: "Log in" (lowercase `in`) instead redirects to Facebook's login page
|
172
|
+
# rescue Capybara::ElementNotFound; end # If we can't find it don't break horribly, just keep waiting
|
173
|
+
|
174
|
+
# break unless has_css?('p[data-testid="login-error-message"', wait: 10)
|
175
|
+
# loop_count += 1
|
176
|
+
# sleep(rand * 10.3)
|
177
|
+
# end
|
178
|
+
|
179
|
+
# # Sometimes Instagram just... doesn't let you log in
|
180
|
+
# raise "Instagram not accessible" if loop_count == 5
|
181
|
+
|
182
|
+
# # No we don't want to save our login credentials
|
183
|
+
# begin
|
184
|
+
# click_on("Save Info")
|
185
|
+
# rescue Capybara::ElementNotFound; end
|
186
|
+
# end
|
186
187
|
|
187
188
|
def fetch_image(url)
|
188
189
|
request = Typhoeus::Request.new(url, followlocation: true)
|
data/lib/birdsong/version.rb
CHANGED
data/lib/birdsong.rb
CHANGED
@@ -23,6 +23,7 @@ module Birdsong
|
|
23
23
|
class InvalidIdError < Error; end
|
24
24
|
class InvalidMediaTypeError < Error; end
|
25
25
|
class NoTweetFoundError < Error; end
|
26
|
+
class WebDriverError < Error; end
|
26
27
|
class RateLimitExceeded < Error
|
27
28
|
attr_reader :rate_limit
|
28
29
|
attr_reader :rate_remaining
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birdsong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Guess
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
|
-
rubygems_version: 3.4.
|
203
|
+
rubygems_version: 3.4.20
|
204
204
|
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: A gem to interface with Twitter's API V2
|