stealth_browser_automation 1.1.20 → 1.1.25

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: 0964be1f00d2a923bcb474e9cd1a97ba25ddc129
4
- data.tar.gz: 4e102526143d94c3fb6c99df7fc09619766ca89d
3
+ metadata.gz: 2f38926d28e0432ca3b7cc915917f61c4c3cb195
4
+ data.tar.gz: 85bf072c269c336be834287110b33adb0a51742b
5
5
  SHA512:
6
- metadata.gz: b12c07cb72a9e919eba74193298f8779afacb54190a0d466521be38dd28d7982068ad9a2738f1b7fab2e9eacc84996437df73404faee8a0194dd95189545f702
7
- data.tar.gz: 052fc21921ff852129f2a3d4d85377f27190ccb3f4e7edb479631d8dc629725cd2abe07e2b1041ce3b15b06b5d57b7d2ac7a624291acebfca3e37fdf66d47051
6
+ metadata.gz: e8797630080f9de87c4e5dd0041e0410cb3d1c0c2d4df626912c961bb56edcc3dbb2e5ead9457aed27184a9d3fd564d0e4247e5bee649c26dddbc90201c193fc
7
+ data.tar.gz: 9db19bed23e1798d3462bcf9608d600beaab60bb72f7918f5a7508fbee709673626eeb30b6b72f8d4dc7e5a2f0e2df04412a9d188c667f53621a134fc6520b61
@@ -570,14 +570,14 @@ module BlackStack
570
570
  #@@browser.close if !@@browser.nil?
571
571
  rescue
572
572
  end
573
-
573
+ =begin
574
574
  begin
575
575
  # TODO: entender porque debo hacer esta llamada a start para que el perfil se cierre cuando ya estaba iniciado
576
576
  BlackStack::BrowserFactory.mimic(@@profile_name) if !@@profile_name.nil?
577
577
  rescue
578
578
  # nothing here
579
579
  end
580
-
580
+ =end
581
581
  i = 0
582
582
  max = 3
583
583
  success = false
@@ -589,7 +589,7 @@ module BlackStack
589
589
  res = JSON.parse(body)
590
590
  success = true if res['status'].to_s == 'OK'
591
591
  end # while i<max
592
- raise 'Error requesting Mimic to stop (tried #{i.to_s} times)' if !success
592
+ raise "Error requesting Mimic to stop (tried #{i.to_s} times)" if !success
593
593
 
594
594
  else
595
595
  raise 'Cannot destroy browser due unknown browser type'
@@ -654,6 +654,12 @@ module BlackStack
654
654
  while (i<max && url_2.nil?)
655
655
  i += 1
656
656
 
657
+ # cierro el perfil por si estaba corriendo
658
+ url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port}/api/v1/profile/stop?profileId=#{@@profile_name}"
659
+ uri = URI.parse(url)
660
+ body = Net::HTTP.get(uri)
661
+ res = JSON.parse(body)
662
+
657
663
  url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port}/api/v1/profile/start?automation=true&profileId=#{@@profile_name}"
658
664
  uri = URI.parse(url)
659
665
  body = Net::HTTP.get(uri)
@@ -50,31 +50,39 @@ module BlackStack
50
50
 
51
51
  # returns the profileId of the new Mimic profile
52
52
  def self.remove_local_profile(profile_id)
53
- url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port.to_s}/api/v2/localprofile/remove?profileId=#{profile_id}"
53
+ url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port.to_s}/api/v2/localprofile/remove"
54
54
  uri = URI.parse(url)
55
- req = Net::HTTP::Post.new(uri)
56
- req['Content-Type'] = 'application/json'
57
55
  res = Net::HTTP.start(uri.host, uri.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|
58
- http.request(req)
56
+ req = Net::HTTP::Post.new(uri)
57
+ req['Content-Type'] = 'application/json'
58
+ req.body = [profile_id].to_json
59
+ res = JSON.parse(http.request(req).body)
60
+ raise "Error creating Multilogin local profile: #{res.to_s}" if res['status'] != 'OK'
61
+ return
59
62
  }
60
- res = JSON.parse(res.body)
61
- raise "Error removing Multilogin local profile: #{res.to_s}" if !res.has_key?('status')
62
- raise "Error removing Multilogin local profile: #{res['status'].to_s}" if res['status'] != 'OK'
63
63
  end # def self.delete_profile
64
64
 
65
65
  # returns the profileId of the new Mimic profile
66
+ # TODO: validar posibles errores
66
67
  def self.local_profiles()
67
68
  url = "http://127.0.0.1:#{BlackStack::StealthBrowserAutomation::Multilogin::mla_local_port.to_s}/api/v2/localprofile/list"
68
69
  uri = URI.parse(url)
69
- req = Net::HTTP::Post.new(uri)
70
- req['Content-Type'] = 'application/json'
71
70
  res = Net::HTTP.start(uri.host, uri.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) {|http|
72
- http.request(req)
71
+ req = Net::HTTP::Get.new(uri)
72
+ #req['Content-Type'] = 'application/json'
73
+ #req.body = {}.to_json
74
+ res = JSON.parse(http.request(req).body)
75
+ #raise "Error creating Multilogin local profile: #{res.to_s}" if res['status'] != 'OK'
76
+ return res
73
77
  }
74
- res = JSON.parse(res.body)
75
- raise "Error getting Multilogin local profiles: #{res.to_s}" if !res.has_key?('status')
76
- raise "Error getting Multilogin local profiles: #{res['status'].to_s}" if res['status'] != 'OK'
77
- res
78
+ end # def self.delete_profile
79
+
80
+ # returns the profile_id from its name.
81
+ # If not exists a profile with such name, it returns nil.
82
+ def self.local_profile_id(name)
83
+ h = self.local_profiles.select { |h| h['name'] == name }.first
84
+ return nil if h.nil?
85
+ h['sid']
78
86
  end # def self.delete_profile
79
87
 
80
88
  # returns the profileId of the new Mimic profile
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stealth_browser_automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.20
4
+ version: 1.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-01 00:00:00.000000000 Z
11
+ date: 2020-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mini_magick