FbRuby 0.0.2

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.
@@ -0,0 +1,550 @@
1
+ require 'uri'
2
+ require_relative 'posts.rb'
3
+ require_relative 'login.rb'
4
+ require_relative 'chats.rb'
5
+ require_relative 'exceptions.rb'
6
+
7
+ module FbRuby
8
+ # class User di gunakan untuk parsing akun Facebook
9
+ class User
10
+
11
+ attr_reader :this_is_me, :user_info
12
+
13
+ # Inisialisasi object User
14
+ #
15
+ # @param username [String] Nama atau id akun facebook
16
+ # @param requests_sessions [Session] Object Session
17
+ def initialize(username:, requests_sessions:)
18
+ @username = username
19
+ @sessions = requests_sessions
20
+ @url = URI("https://mbasic.facebook.com")
21
+
22
+ @req = @sessions.get(URI.join(@url, @username))
23
+ @res = @req.parse_html
24
+
25
+ raise FbRuby::Exceptions::PageNotFound.new("Akun dengan username #{@username} tidak di temukan") unless @res.at_xpath("//a[starts-with(@href,'/home.php?rand=')]").nil?
26
+
27
+ @user_info = {"name"=>nil,"first_name"=>nil,"middle_name"=>nil,"last_name"=>nil,"alternate_name"=>nil,"about"=>nil,"username"=>nil,"id"=>nil,"contact_info"=>{},"profile_pict"=>nil,"basic_info"=>{},"education"=>[],"work"=>[],"living"=>{},"relationship"=>nil,"other_name"=>[],"family"=>[],"year_overviews"=>{},"quote"=>nil}
28
+
29
+ img = @res.xpath_regex("//img[@alt~=/.*, profile.picture/]").first # Foto Profile Akun
30
+ @user_info['profile_pict'] = img['src'] unless img.nil? # Link Foto Profile
31
+
32
+ name = @res.css("strong[class]").last
33
+
34
+ unless name.nil?
35
+ alt_name = name.at_css("span.alternate_name") #("//span[@class=\"alternate_name\"]") # Nama Lain
36
+ unless alt_name.nil?
37
+ @user_info['alternate_name'] = alt_name.text.gsub(/\(|\)$/,'')
38
+ pisah = name.text.sub(/\(.*\)/,"").strip.split(' ') # Hapus Nama Lain (Alternate Name)
39
+ else
40
+ pisah = name.text.split(' ')
41
+ end
42
+ else
43
+ pisah = []
44
+ end
45
+
46
+ @user_info['name'] = pisah.join(' ') unless pisah.length.zero?
47
+ @user_info['first_name'] = pisah[0] unless pisah.length.zero?
48
+ @user_info['middle_name'] = pisah[1] if pisah.length > 2
49
+ @user_info['last_name'] = pisah[-1] if pisah.length >= 2
50
+
51
+ # Bio
52
+ bio = @res.at_xpath("//div[@id=\"bio\"]")
53
+
54
+ unless bio.nil?
55
+ bio.xpath("//a[starts-with(@href, '/profile/edit')]").each{|e| e.remove}
56
+ @user_info['about'] = bio.search('text()').map(&:text)[-1]
57
+ end
58
+
59
+ # Id Pengguna
60
+ uid = @res.at_css("img[alt*='profile picture']").parent
61
+ uid = @res.at_css("a[href^='/profile/picture/view']") if uid['href'].nil?
62
+
63
+ unless uid.nil?
64
+ cari_uid = uid['href'].match(/(?:&|;|profile_)id=(\d+)/)
65
+ @user_info['id'] = cari_uid[-1] unless cari_uid.nil?
66
+ else
67
+ cari_uid = @req.body.match(/owner_id=(\d+)/)
68
+ @user_info['id'] = cari_uid[1] unless cari_uid.nil?
69
+ end
70
+
71
+ # Nama Pengguna (username)
72
+ unless @req.request.url.include? ('profile.php')
73
+ username = @req.request.url.match(/^(?:https?:\/\/)?(?:www\.)?mbasic\.facebook\.com\/([a-zA-Z0-9.]+)/)
74
+ @user_info['username'] = username[-1] unless username.nil?
75
+ end
76
+
77
+ # Informasi tentang sekolah
78
+ sekolah = @res.at_xpath("//div[@id=\"education\"]")
79
+
80
+ unless sekolah.nil?
81
+ sekolah.xpath_regex("//a[@href~=/(\/editprofile\/eduwork\/add\/|\/profile\/edit)/]").map(&:remove)
82
+
83
+ sekolah.css("img").map do |img|
84
+ parent = img.parent.next_element
85
+ next if parent.nil? or parent.name != 'div'
86
+ arr_sekolah = parent.css('span').map(&:text).uniq
87
+ hash_sekolah = {'name'=>nil,'type'=>nil,'study'=>nil,'time'=>nil}
88
+
89
+ case arr_sekolah.length
90
+ when 1 then hash_sekolah['name'] = arr_sekolah.first
91
+ when 2 then hash_sekolah.update({'name'=>arr_sekolah.first,'time'=>arr_sekolah.last})
92
+ when 3 then hash_sekolah.update({'name'=>arr_sekolah.first,'type'=>arr_sekolah[1],'time'=>arr_sekolah.last})
93
+ when 4 then hash_sekolah.update({'name'=>arr_sekolah.first,'type'=>arr_sekolah[1], 'study'=>arr_sekolah[2], 'time'=>arr_sekolah.last})
94
+ end
95
+
96
+ @user_info['education'] << hash_sekolah
97
+ end
98
+ end
99
+
100
+ # Informasi Tentang Pekerjaan
101
+ kerja = @res.at_xpath("//div[@id=\"work\"]")
102
+
103
+ unless kerja.nil?
104
+ loker = kerja.search('img').select{|met| met['alt'].to_s.match? (/(.*?), profile picture/)}
105
+
106
+ for echa in loker
107
+ moya = echa.parent.next_element
108
+ next if moya.nil? or moya.name != 'div'
109
+
110
+ # Alay dikit gak papa lah:v
111
+ rahmat_sayang_khaneysia = moya.css('text()').map(&:text).uniq
112
+ rahmat_cinta_khaneysia = rahmat_sayang_khaneysia.first # Nama pekerjaan
113
+ love_you_khaneysia = rahmat_sayang_khaneysia.select{|echa| echa.match? (/^(\d{1}|\d{2}|\u200f)(\d{1}|\d{2}|\s)(.*?)\s-(.*?)$/)}.first
114
+ # Heheh :>
115
+
116
+ @user_info['work'] << {'name'=>rahmat_cinta_khaneysia,'time'=>love_you_khaneysia}
117
+ end
118
+ end
119
+
120
+ # Informasi Tentang Tempat Tinggal
121
+ rumah = @res.at_xpath("//div[@id=\"living\"]")
122
+
123
+ unless rumah.nil?
124
+ rumah.xpath("//a[starts-with(@href,\"editprofile.php\")]").map(&:remove)
125
+ rumah_arr = rumah.css('text()').map(&:text)[1..]
126
+ rumah_arr.each_slice(2){|key,val| @user_info['living'].update({key=>val})}
127
+ end
128
+
129
+ # Informasi Tentang Nama Lain
130
+ other_name = @res.at_xpath("//div[@id=\"nicknames\"]")
131
+
132
+ unless other_name.nil?
133
+ other_name.xpath("//a[starts-with(@href,\"/profile/edit/info/nicknames\")]").map(&:remove)
134
+ nama_ku = other_name.css('text()').map(&:text)[1..]
135
+ nama_ku.each_slice(2){|key, val| @user_info['other_name'] << {key=>val}}
136
+ end
137
+
138
+ # Informasi Tentang Hubungan Percintaan
139
+ cinta = @res.at_xpath("//div[@id=\"relationship\"]")
140
+
141
+ unless cinta.nil?
142
+ cinta.xpath("//a[starts-with(@href,\"/editprofile.php\")]").map(&:remove)
143
+ cinta_ku = cinta.css('text()').map(&:text).map(&:strip)[1..]
144
+ @user_info['relationship'] = cinta_ku.join(' ')
145
+ end
146
+
147
+ # Informasi Tentang Anggota keluarga
148
+ # Harta Yang Paling Berharga Adalah Keluarga :) #
149
+ keluarga = @res.at_xpath("//div[@id=\"family\"]")
150
+
151
+ unless keluarga.nil?
152
+ keluarga_ku = keluarga.css('img').select{|i| i['alt'].to_s.match(/(.*), profile picture/)}
153
+
154
+ for family in keluarga_ku
155
+ parent = family.parent.next_element
156
+ name = parent.css('a').text
157
+ profile_pict = family['src']
158
+ designation = parent.css('h3')[-1].text
159
+
160
+ @user_info['family'] << {'name'=>name,'profile_pict'=>profile_pict,'designation'=>designation}
161
+ end
162
+ end
163
+
164
+ # Informasi Tentang Peristiwa Penting dalam Hidup
165
+ kejadian = @res.at_xpath("//div[@id=\"year-overviews\"]")
166
+
167
+ unless kejadian.nil?
168
+ # 23-08-2021
169
+ khaneysia = kejadian.at('div').css('text()').map(&:text)[1..]
170
+ nabila = {}
171
+ zahra = nil
172
+
173
+ khaneysia.each do |element|
174
+ if element.match?(/^\d+$/) # Jika elemen merupakan tahun
175
+ zahra = element
176
+ nabila[zahra] = []
177
+ elsif zahra
178
+ nabila[zahra] << element
179
+ end
180
+ end
181
+ # 22/11/2021 #
182
+ @user_info['year_overviews'].update(nabila)
183
+ end
184
+
185
+ # Kutipan Favorite
186
+ kutipan = @res.at_xpath("//div[@id=\"quote\"]")
187
+
188
+ unless kutipan.nil?
189
+ kutipan.xpath("//a[starts-with(@href, \"/profile/edit/\")]").map(&:remove)
190
+ content = kutipan.css('text()').map(&:text).map(&:strip)[1..]
191
+ @user_info['quote'] = content.join(' ')
192
+ end
193
+
194
+ # Informasi Kontak
195
+ contact = @res.at_xpath("//div[@id=\"contact-info\"]")
196
+
197
+ unless contact.nil? then contact.css('text()').map(&:text).map(&:strip)[1..].each_slice(2){|k,v| @user_info['contact_info'].update({k=>v})}
198
+ end
199
+
200
+ # Informasi Umum
201
+ basic_info = @res.at_xpath("//div[@id=\"basic-info\"]")
202
+
203
+ unless basic_info.nil? then basic_info.css('text()').map(&:text).map(&:strip)[1..].each_slice(2){|k,v| @user_info['basic_info'].update({k=>v})}
204
+ end
205
+
206
+ my_id = @sessions.get_cookie_hash['c_user']
207
+
208
+ unless my_id.nil?
209
+ @this_is_me = my_id == @user_info['id']
210
+ end
211
+ end
212
+
213
+ # Mengembalikan string representasi dari objek User.
214
+ #
215
+ # @return [String] Representasi string dari objek User.
216
+ def to_s
217
+ return "Facebook User : name=#{@user_info['name'].inspect} username=#{@user_info['username'].inspect} id=#{@user_info['id'].inspect}"
218
+ end
219
+
220
+ # Mengembalikan string representasi dari objek User.
221
+ #
222
+ # @return [String] Representasi string dari objek User.
223
+ def inspect
224
+ return self.to_s
225
+ end
226
+
227
+ def [](item)
228
+ return @user_info[item]
229
+ end
230
+
231
+ def method_missing(method_name, *args)
232
+ key = method_name.to_s
233
+ if @user_info.key?(key)
234
+ return @user_info[key]
235
+ else
236
+ super
237
+ end
238
+ end
239
+
240
+ def respond_to_missing?(method_name, include_private = false)
241
+ @user_info.key?(method_name.to_s) || super
242
+ end
243
+
244
+ # refresh page
245
+ def refresh
246
+ initialize(username:@username, requests_sessions:@sessions)
247
+ end
248
+
249
+ # Colek Orang ini
250
+ def poke
251
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat melakukan poke ke diri sendiri") if @this_is_me
252
+ colek = @res.at_xpath("//a[starts-with(@href,\"/pokes/inline\")]")
253
+
254
+ unless colek.nil?
255
+ req = @sessions.get(URI.join(@url, colek['href']))
256
+ gagal = req.parse_html.at_css("div[text()^=\"#{@user_info['name']}\"]")
257
+ raise FbRuby::Exceptions::FacebookError.new(gagal.text) unless gagal.nil?
258
+ return req.ok?
259
+ end
260
+ end
261
+
262
+ # Buat pesan baru dengan orang ini
263
+ #
264
+ # @return [Chats]
265
+ def message
266
+ chat_url = @res.at_css('a[href^="/messages/thread/"]')
267
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat mengirim pesan ke #{@user_info['name']}") if chat_url.nil?
268
+
269
+ return FbRuby::Chats.new(chats_url: URI.join(@url, chat_url['href']), request_session: @sessions)
270
+ end
271
+
272
+ # Shortcut untuk kirim pesan teks ke orang ini
273
+ def send_text(text)
274
+ return message.send_text(text)
275
+ end
276
+
277
+ # Blokir akun orang ini
278
+ def block_user
279
+ block_url = @res.at_css("a[href^='/privacy/touch/block/confirm/']")
280
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat memblokir akun sendiri :)") if @this_is_me
281
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat memblokir akun #{self['name']}") if block_url.nil?
282
+
283
+ req = @sessions.get(URI.join(@url, block_url['href']))
284
+ res = req.parse_html
285
+
286
+ form = res.at_css("form[action^='/privacy/touch/block']")
287
+ data = {}
288
+ form.css('input[type="hidden"]').each{|i| data[i['name']] = i['value']}
289
+ data["confirmed"] = form.at_css('input[name="confirmed"]')['value']
290
+
291
+ blok = @sessions.post(URI.join(@url, form['action']), data = data)
292
+ res = blok.parse_html
293
+
294
+ sukses = res.at_css("a[href^=\"/privacy/touch/block/?block_result=0\"]")
295
+
296
+ return !sukses.nil?
297
+ end
298
+
299
+ # Tambahkan orang ini sebagai teman
300
+ def add_friends
301
+ action_user("/a/friends/profile/add")
302
+ end
303
+
304
+ # Batalkan permintaan pertemanan
305
+ def cancel_friends_requests
306
+ action_user("/a/friendrequest/cancel")
307
+ end
308
+
309
+ # Terima permintaan pertemanan
310
+ def accept_friends_requests
311
+ action_user_with_regex("/a\/friends\/profile\/add\/\?(.*)is_confirming/")
312
+ end
313
+
314
+ # Hapus permintaan pertemanan
315
+ def delete_friends_requests
316
+ action_user_with_regex("/\/a(.*?)friends\/reject/")
317
+ end
318
+
319
+ # Hapus pertemanan
320
+ def remove_friends
321
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat melakukan tindakan yang anda minta!") if @this_is_me
322
+ confirm = @res.at_css('a[href^="/removefriend.php?"]')
323
+
324
+ unless confirm.nil?
325
+ confirm_form = @sessions.get(URI.join(@url, confirm['href'])).parse_html.at_css('form[action^="/a/friends/remove/"]')
326
+ confirm_data = {}
327
+ unless confirm_form.nil?
328
+ confirm_form.css('input[@type="hidden"]').each{|inp| confirm_data.update({inp['name']=>inp['value']})}
329
+ confirm_data.update({"confirm"=>confirm_form.at_css('input[@name="confirm"]')['value']})
330
+ confirm_submit = @sessions.post(URI.join(@url, confirm_form['action']), data = confirm_data)
331
+ @res = confirm_submit.parse_html
332
+
333
+ return confirm_submit.ok?
334
+ end
335
+ end
336
+ end
337
+
338
+ # Ikuti akun ini
339
+ def follow
340
+ action_user("/a/subscribe.php")
341
+ end
342
+
343
+ # Berhenti mengikuti akun ini
344
+ def unfollow
345
+ action_user("/a/subscriptions/remove")
346
+ end
347
+
348
+ # Dapatkan daftar teman
349
+ #
350
+ # @param limit [Integer] Batas maksimal atau jumblah yang ingin di dapatkan
351
+ # @param return_hash [Boolean] Kembalikan Hash jika true
352
+ def get_friends(limit, return_hash = true)
353
+ return getFriends("?v=friends",limit,return_hash)
354
+ end
355
+
356
+ # Dapatkan daftar teman yang memiliki kesamaan
357
+ #
358
+ # @param limit [Integer] Batas maksimal atau jumblah yang ingin di dapatkan
359
+ # @param return_hash [Boolean] Kembalikan Hash jika true
360
+ def get_mutual_friends(limit, return_hash = true)
361
+ return getFriends("?v=friends&mutual=1",limit,return_hash)
362
+ end
363
+
364
+ # Dapatkan Foto Dari Akun Pengguna
365
+ #
366
+ # @param limit[Integer] Jumblah foto yang akan di ambil
367
+ # @param albums_url[String] Url dari album foto
368
+ def get_photo(limit = 5, albums_url = nil)
369
+ raise FbRuby::Exceptions::FacebookError.new("Format url album tidak valid!") if !albums_url.nil? and !albums_url.match?(/^https:\/\/(.*?)\.facebook\.com\/[a-zA-Z0-9_.-]+\/albums\/\d+\/(.*)/)
370
+ myPhoto = []
371
+
372
+ if albums_url.nil?
373
+ html = @sessions.get(URI.join(@url, "#{@username}?v=photos")).parse_html
374
+ else
375
+ html = @sessions.get(albums_url).parse_html
376
+ end
377
+
378
+ while myPhoto.length < limit
379
+ img = html.css("a[href^='/photo.php']")
380
+ break if img.length < 2
381
+ thread = FbRuby::Utils::ThreadPool.new(size: 5)
382
+ img[1...].each do |i|
383
+ thread.schedule do
384
+ myPhoto << getImage(i)
385
+ end
386
+ end #Lanjut di sini
387
+ thread.shutdown
388
+ next_url = html.at_css("a[href*='/photoset'], a[href*='/albums'][href*='start_index']")
389
+ break if myPhoto.length >= limit or next_url.nil?
390
+ html = @sessions.get(URI.join(@url, next_url['href'])).parse_html
391
+ end
392
+
393
+ return myPhoto[0...limit]
394
+ end
395
+
396
+ # Dapatkan Album Dari Akun Pengguna
397
+ #
398
+ # @param limit[Integer] Jumblah maksimal album yang akan di ambil
399
+ def get_albums(limit = 5)
400
+ myalbums = []
401
+ html = @sessions.get(URI.join(@url, "/#{@username}?v=albums")).parse_html
402
+ album = html.css("a[href*='/albums']")
403
+ album.each{|i| myalbums << {"albums_name"=>i.text, "albums_url"=>URI.join(@url, i['href']).to_s}}
404
+
405
+ return myalbums[0...limit]
406
+ end
407
+
408
+ # Dapatkan Postingan dari Akun Pengguna
409
+ # @param limit[Integer] Jumblah maksimal Postingan yang akan di ambil
410
+ def get_posts(limit = 5)
411
+ myPosts = []
412
+ html = @sessions.get(URI.join(@url, "#{@username}?v=timeline")).parse_html
413
+
414
+ while myPosts.length < limit
415
+ for post in html.css("div[role='article']")
416
+ url = post.at_css("a[href^='/story.php'][href*='#footer_action_list']")
417
+ next if url.nil?
418
+ break if myPosts.length >= limit
419
+ myPosts << FbRuby::Posts.new(post_url: URI.join(@url,url['href']).to_s, request_session: @sessions)
420
+ end
421
+
422
+ next_url = html.at_css("a[href^='/profile/timeline/stream']")
423
+ break if myPosts.length >= limit or next_url.nil?
424
+ html = @sessions.get(URI.join(@url, next_url['href'])).parse_html
425
+ end
426
+
427
+ return myPosts[0...limit]
428
+ end
429
+
430
+ # Buat Postingan di akun pengguna
431
+ #
432
+ # @param message[String] Caption dari postingan
433
+ # @param file[String] Path dari foto (hanya bisa posting 1 foto)
434
+ # @param location[String] Nama Kota / Nama tempat
435
+ # @param feeling[String] Nama Perasaan
436
+ # @param filter_type[String] Tipe Filter
437
+ # Ada 3 tipe filter
438
+ # -1 Tanpa Filter
439
+ # 2 Hitam Putih
440
+ # 3 Retro
441
+ def create_timeline(message, file: nil, location: nil,feeling: nil,filter_type: '-1', **kwargs)
442
+ fullForm = @res.at_xpath("//form[starts-with(@action,'/composer/mbasic')]")
443
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat membuat postingan ke akun \"#{self.name}\" :(") if fullForm.nil?
444
+ fullFormData = {}
445
+ fullForm.css("input[type = 'hidden']").each{|i| fullFormData[i['name']] = i['value']}
446
+ html = @sessions.post(URI.join(@url, fullForm['action']), data = fullFormData).parse_html
447
+ return FbRuby::Utils::create_timeline(html,@sessions, message, file, location, feeling, filter_type, **kwargs)
448
+ end
449
+
450
+ private
451
+ def getFriends(friends, limit = 25, return_hash = true)
452
+ teman = []
453
+ friendsUrl = URI.join(@url, @username, friends)
454
+
455
+ while teman.length < limit
456
+ neysia = @sessions.get(friendsUrl)
457
+ moyaM = neysia.parse_html
458
+ datas = moyaM.css('img').select{|img| img['alt'].to_s.match?(/(.*), profile picture/)}
459
+ datas.delete_at(0) unless datas.length.zero?
460
+ break if datas.length.zero?
461
+
462
+ if return_hash
463
+ datas.each do |elm|
464
+ profile = get_profile_info(elm)
465
+ next if profile.nil?
466
+ teman << profile
467
+ end
468
+ else
469
+ threadPool = FbRuby::Utils::ThreadPool.new(size: 5)
470
+
471
+ datas.each do |elm|
472
+ profile = get_profile_info(elm)
473
+ next if profile.nil?
474
+ threadPool.schedule {teman << FbRuby::User.new(username: profile['username'], requests_sessions: @sessions)}
475
+ end
476
+
477
+ threadPool.shutdown
478
+ end
479
+ next_url = moyaM.xpath_regex("//a[@href~=/^(\/profile\.php\?id=\d+(.*)v=friends)/]").first
480
+ break if next_url.nil? or teman.length >= limit
481
+ friendsUrl = URI.join(@url, next_url['href'])
482
+ end
483
+ return teman
484
+ end
485
+
486
+
487
+ def action_user(first_url)
488
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat melakukan tindakan yang anda minta!") if @this_is_me
489
+ moya = @res.at_css("a[href^='#{first_url}']")
490
+
491
+ unless moya.nil?
492
+ rahmat = @sessions.get_without_sessions(URI.join(@url, moya['href']))
493
+ @res = rahmat.parse_html
494
+
495
+ return rahmat.ok?
496
+ else
497
+ return false
498
+ end
499
+ end
500
+
501
+ def action_user_with_regex(regex)
502
+ raise FbRuby::Exceptions::FacebookError.new("Tidak dapat melakukan tindakan yang anda minta!") if @this_is_me
503
+ moya = @res.xpath_regex("//a[@href~=#{regex}]").first
504
+
505
+ unless moya.nil?
506
+ neysia = {"jazoest"=>@res.at_css("input[name=\"jazoest\"]")['value'],"fb_dtsg"=>@res.at_css("input[name=\"fb_dtsg\"]")['value']}
507
+ rahmat = @sessions.get(URI.join(@url, moya['href']), data = neysia)
508
+ @res = rahmat.parse_html
509
+ return rahmat.ok?
510
+ else
511
+ return false
512
+ end
513
+ end
514
+
515
+ def get_profile_info(nokogiri_obj)
516
+ parent = nokogiri_obj.parent
517
+ pola = /^\/profile\.php\?id=(\d+)|^\/([a-zA-Z0-9_.-]+)/
518
+
519
+ unless parent.nil?
520
+ profile = parent.next_element.xpath_regex(".//a[@href~=/#{pola}/]").first
521
+ profile_url = profile['href']
522
+ username = profile_url.match(pola)
523
+ return {"name"=>profile.text, "username"=>(username[1].nil?) ? username[2] : username[1], "profile_url"=>URI.join(@url, profile_url).to_s, "profile_pict"=>nokogiri_obj['src']}
524
+ else
525
+ return nil
526
+ end
527
+ end
528
+
529
+ def getImage(nokogiriObj)
530
+ data = {"thumbnail"=>nil,"photo"=>nil,"albums"=>nil,"albums_url"=>nil}
531
+
532
+ begin
533
+ thumbnail = nokogiriObj.at_css("img")
534
+ photo = @sessions.get(URI.join(@url, nokogiriObj['href'])).parse_html
535
+ albums = photo.at_css("a[href*='/albums']")
536
+ fullImg = photo.xpath_regex("//img[@src~=/^https:\/\/(?:z-m-scontent|scontent)/]").first
537
+
538
+ data["thumbnail"] = thumbnail['src'] unless thumbnail.nil?
539
+ data["photo"] = fullImg["src"] unless fullImg.nil?
540
+
541
+ unless albums.nil?
542
+ data["albums"] = albums.text
543
+ data["albums_url"] = URI.join(@url, albums['href']).to_s
544
+ end
545
+ ensure
546
+ return data
547
+ end
548
+ end
549
+ end
550
+ end