zorki 0.1.21 → 0.1.23

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: '0228694f5aafe38a9856efe3a4f9f042b94aeecbd5cb7ec919326f48c0b8000e'
4
- data.tar.gz: c54da1aa5b98d3166a047a24022b74356538e7dcb974e032bc5236065c5edd4c
3
+ metadata.gz: 59b7b2ee84517a52b4c4bfaa300fe18d5981789c92c5983cc07d2cbe21323a79
4
+ data.tar.gz: 6d24c1955520c08164da77783dbbc17d8db09edfa8de30103a3ddfcdaeaf8064
5
5
  SHA512:
6
- metadata.gz: 30b2953e778ce0a6e36f221350c6760974de7279c764111cfe2327f3bcc5f11a93d19a4747d20c35260038e07c06bad2c3d2fc704b4878c23a41ba309ae689d9
7
- data.tar.gz: 99ed979bcc6f4f0758bca49d34580333ba42c35d74ce3ccfe52871acb9665d3841e0d54ed68bb3af2cf1ef366ebb1f3f9ea9136784958778751d7142f09e5b38
6
+ metadata.gz: 3bb4c7df50e497920f6e21216268a2640128f0b0fee6d443827ffe372f720a63b03fe6ad0c62d2a78862698989e7b62929bd9d0e9c54e5dcf12c8a5ccca85719
7
+ data.tar.gz: 1cee6eafb78aaf2bcadc855f44676501996ce83c9fc5a3ecafc5303fc7a62d2ee7aa0730b78477c8578fd1edc3e897317ee6014cfd35b38d5743816ebf8307e4
@@ -41,7 +41,7 @@ module SeleniumMonkeypatch
41
41
  data[:sessionId] = @session_id if @session_id
42
42
  message = @ws.send_cmd(**data)
43
43
  if message.nil? == false && message["error"] && (method != "Fetch.continueRequest")
44
- raise Error::WebDriverError, error_message(message["error"])
44
+ raise Selenium::WebDriver::Error::WebDriverError, error_message(message["error"])
45
45
  end
46
46
 
47
47
  message
@@ -14,7 +14,6 @@ module Zorki
14
14
  result = attempt_parse(id)
15
15
  break
16
16
  rescue ImageRequestZeroSize
17
- debugger
18
17
  # If the image is zero size, we retry
19
18
  puts "Zero sized image found, retrying #{count}"
20
19
  count += 1
@@ -24,6 +23,9 @@ module Zorki
24
23
  raise ImageRequestZeroSize if count == 5
25
24
 
26
25
  result
26
+ ensure
27
+ page.quit
28
+ # Make sure it's quit? I'm not sure we really want to do this outside of testing.
27
29
  end
28
30
 
29
31
  def attempt_parse(id)
@@ -45,6 +47,7 @@ module Zorki
45
47
  "data,xdt_api__v1__media__shortcode__web_info,items"
46
48
  )
47
49
 
50
+
48
51
  graphql_object = graphql_object.first if graphql_object.kind_of?(Array)
49
52
 
50
53
  # For pages that have been marked misinfo the structure is very different than not
@@ -62,6 +65,7 @@ module Zorki
62
65
  text = graphql_object["articleBody"]
63
66
  username = graphql_object["author"]["identifier"]["value"]
64
67
  # 2021-04-01T17:07:10-07:00
68
+
65
69
  date = DateTime.strptime(graphql_object["dateCreated"], "%Y-%m-%dT%H:%M:%S%z")
66
70
  interactions = graphql_object["interactionStatistic"]
67
71
  number_of_likes = interactions.select do |x|
@@ -72,8 +72,9 @@ module Zorki
72
72
 
73
73
  continue.call(request) do |response|
74
74
  # Check if not a CORS prefetch and finish up if not
75
- if !response.body.empty? && response.body
75
+ if !response.body&.empty? && response.body
76
76
  check_passed = true
77
+
77
78
  unless additional_search_parameters.nil?
78
79
  body_to_check = Oj.load(response.body)
79
80
 
@@ -119,7 +120,16 @@ module Zorki
119
120
  begin
120
121
  element_json = JSON.parse(element.text)
121
122
 
122
- parsed_element_json = element_json["require"].first.last.first["__bbox"]["require"].first.last.last["__bbox"]["result"]["data"]["xdt_api__v1__media__shortcode__web_info"]
123
+ if element.text.include?("Dwayne")
124
+ # if element_json["require"].first.last.first["__bbox"].key?("require")
125
+
126
+ # element_json["require"].first.last.first["__bbox"]["require"].each do |x|
127
+ # debugger if x.to_s.include?("Dwayne Johnson")
128
+ # end
129
+ # end
130
+ end
131
+
132
+ parsed_element_json = element_json["require"].last.last.first["__bbox"]["require"].first.last.last["__bbox"]["result"]["data"]["xdt_api__v1__media__shortcode__web_info"]
123
133
  rescue StandardError
124
134
  next
125
135
  end
@@ -137,9 +147,10 @@ module Zorki
137
147
  raise ContentUnavailableError.new("Response body nil") if response_body.nil?
138
148
  Oj.load(response_body)
139
149
  ensure
140
- page.quit
150
+ # page.quit
141
151
  # TRY THIS TO MAKE SURE CHROME GETS CLOSED?
142
152
  # We may also want to not do this and make sure the same browser is reused instead for cookie purposes
153
+ # NOW wer'e trying this 2024-05-28
143
154
  end
144
155
 
145
156
  private
@@ -18,7 +18,7 @@ module Zorki
18
18
  # - *Profile image
19
19
  login
20
20
 
21
- graphql_script = get_content_of_subpage_from_url("https://instagram.com/#{username}/", "?username=")
21
+ graphql_script = get_content_of_subpage_from_url("https://instagram.com/#{username}/", "graphql", "data,user,full_name")
22
22
  graphql_script = graphql_script.first if graphql_script.class == Array
23
23
 
24
24
  if graphql_script.nil?
@@ -62,13 +62,13 @@ module Zorki
62
62
  scraped_username = user["username"]
63
63
  raise Zorki::Error unless username == scraped_username
64
64
 
65
- profile_image_url = user["profile_pic_url_hd"]
65
+ profile_image_url = user["hd_profile_pic_url_info"]["url"]
66
66
  {
67
67
  name: user["full_name"],
68
68
  username: username,
69
- number_of_posts: user["edge_owner_to_timeline_media"]["count"],
70
- number_of_followers: user["edge_followed_by"]["count"],
71
- number_of_following: user["edge_follow"]["count"],
69
+ number_of_posts: user["media_count"],
70
+ number_of_followers: user["follower_count"],
71
+ number_of_following: user["following_count"],
72
72
  verified: user["is_verified"],
73
73
  profile: user["biography"],
74
74
  profile_link: user["external_url"],
data/lib/zorki/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zorki
4
- VERSION = "0.1.21"
4
+ VERSION = "0.1.23"
5
5
  end
data/lib/zorki.rb CHANGED
@@ -64,8 +64,6 @@ module Zorki
64
64
  return temp_file_name if File.size(temp_file_name) > 100
65
65
 
66
66
  # Delete the file since we want to retry
67
- debugger
68
-
69
67
  File.delete(temp_file_name)
70
68
  count += 1
71
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zorki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Guess
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-29 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara