zorki 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zorki/scrapers/post_scraper.rb +3 -1
- data/lib/zorki/user.rb +46 -0
- data/lib/zorki/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc52913230d63a501d9d7fba1ebb80f11cd5f47031711d0cb287da2a6b16fc93
|
4
|
+
data.tar.gz: 0c4aec5fcdf10a82265e9f2c405021ced45dd2c76e1e5b4ed9b8cbd275d680cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80036f9121369b7684ef6ba739be20c83b305c53c4959f7af8918a573f0af1755a4793a8f8c089b1040618bf8c6c15229948de8d7383c10dc5b67cb63bd6a7bc
|
7
|
+
data.tar.gz: b3cb6f9e5846df66990294c78f8aa925e5205e413a7ef463affa9a165c98cb5cb8a24e6110b3d90486425549899d87bff8ce3872384a57cbca0baf634f2005d8
|
@@ -165,12 +165,14 @@ module Zorki
|
|
165
165
|
images << Zorki.retrieve_media(object["display_resources"].last["src"])
|
166
166
|
end
|
167
167
|
end
|
168
|
+
|
169
|
+
user = User.from_post_data(object["owner"])
|
168
170
|
end
|
169
171
|
|
170
172
|
screenshot_file = take_screenshot()
|
171
173
|
|
172
174
|
# This has to run last since it switches pages
|
173
|
-
user = User.lookup([username]).first
|
175
|
+
user = User.lookup([username]).first if defined?(user).nil?
|
174
176
|
|
175
177
|
{
|
176
178
|
images: images,
|
data/lib/zorki/user.rb
CHANGED
@@ -12,6 +12,52 @@ module Zorki
|
|
12
12
|
self.scrape(usernames)
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.from_post_data(data)
|
16
|
+
# "owner"=>
|
17
|
+
# {"id"=>"4303258197",
|
18
|
+
# "username"=>"petesouza",
|
19
|
+
# "is_verified"=>true,
|
20
|
+
# "profile_pic_url"=>
|
21
|
+
# "https://scontent-lax3-1.cdninstagram.com/v/t51.2885-19/433045134_436644512119229_523706897615373693_n.jpg?stp=dst-jpg_s150x150&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=1&_nc_ohc=N0A8l8Th9soQ7kNvgH0cKQQ&_nc_gid=29538825d3464a6f9b05bad4506fc1f9&edm=ANTKIIoBAAAA&ccb=7-5&oh=00_AYCIj0oEKb48mFW3Ag4tMW3nJitOdAe91hdIrIM_1nlwEw&oe=67163EE4&_nc_sid=d885a2",
|
22
|
+
# "blocked_by_viewer"=>false,
|
23
|
+
# "restricted_by_viewer"=>nil,
|
24
|
+
# "followed_by_viewer"=>false,
|
25
|
+
# "full_name"=>"Pete Souza",
|
26
|
+
# "has_blocked_viewer"=>false,
|
27
|
+
# "is_embeds_disabled"=>true,
|
28
|
+
# "is_private"=>false,
|
29
|
+
# "is_unpublished"=>false,
|
30
|
+
# "requested_by_viewer"=>false,
|
31
|
+
# "pass_tiering_recommendation"=>true,
|
32
|
+
# "edge_owner_to_timeline_media"=>{"count"=>3596},
|
33
|
+
# "edge_followed_by"=>{"count"=>3166659}},
|
34
|
+
|
35
|
+
new_user_hash = {
|
36
|
+
name: data["full_name"],
|
37
|
+
username: data["username"],
|
38
|
+
number_of_posts: data["edge_owner_to_timeline_media"]["count"],
|
39
|
+
number_of_followers: data["edge_followed_by"]["count"],
|
40
|
+
number_of_following: nil,
|
41
|
+
verified: data["is_verified"],
|
42
|
+
profile: nil,
|
43
|
+
profile_link: "https://www.instagram.com/#{data["username"]}",
|
44
|
+
profile_image: Zorki.retrieve_media(data["profile_pic_url"]),
|
45
|
+
profile_image_url: data["profile_pic_url"]
|
46
|
+
}
|
47
|
+
|
48
|
+
# Now we try and populate the profile
|
49
|
+
begin
|
50
|
+
scraped_user_hash = Zorki::UserScraper.new.parse(data["username"])
|
51
|
+
new_user_hash[number_of_following: scraped_user_hash[:number_of_following]]
|
52
|
+
new_user_hash[profile: scraped_user_hash[:profile]]
|
53
|
+
rescue StandardError
|
54
|
+
puts "#{new_user_hash[:name]}: User created, but cannot fill in the extra data"
|
55
|
+
# If this didn't work we'll eat the error in the interest of completing successfully.
|
56
|
+
end
|
57
|
+
|
58
|
+
User.new(new_user_hash)
|
59
|
+
end
|
60
|
+
|
15
61
|
attr_reader :name,
|
16
62
|
:username,
|
17
63
|
:number_of_posts,
|
data/lib/zorki/version.rb
CHANGED