UrgentcareCLI 0.2.5 → 0.2.6

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: 5bab08152ad85f276f094c6202e03379e6e90581a61746717c92b66518c1cda9
4
- data.tar.gz: 90cdbaf39daf7f4004443e720b9eb9749900122c320a61b0892dea983f11efbe
3
+ metadata.gz: bddaa4f1acd7c513c6416f936fb9274a9539357ce79e2bf042197040ab7fd360
4
+ data.tar.gz: 457704c574b44fb44e63545a52e8f851c702ab58429997060897e5675f8e53b9
5
5
  SHA512:
6
- metadata.gz: 9115429d70b1d4b6e666634af00bb9e84511990c782973731de291c5982b0d26a2d4b2768b657c75b2c6bc5fb3870565ebd0028866911a8231def7d494207f46
7
- data.tar.gz: e4df29cc01aad3a4131bf2c8bfa60f5b55764efb01ec014638275a55fd0155722ab756bbfd255ad3134c06a15bd2eef794a5ec0f386b667a209f2ad66faeae98
6
+ metadata.gz: f18f00d2644fd64c8e062c4acec31f48b595a7b419cb5e166ad3028bf90236a5b3ac6757d12e9eb938dda55ca469c1c7f86d13878976e16271fdd6c9374c3f32
7
+ data.tar.gz: a15fa89db3c04862c6e5af34df56c46f8eec21925104e7c43dd7d0872d539f7b22093a01b8df1ffa8605a6294830e38180a767f4814bbe52108be5828262838d
@@ -26,6 +26,14 @@ class Urgentcare::CLI
26
26
  office_list
27
27
  end
28
28
 
29
+ def loading_message
30
+ puts " "
31
+ puts "Retrieving data...."
32
+ puts "Loading......"
33
+ puts "............."
34
+ puts " "
35
+ end
36
+
29
37
  def office_list
30
38
  @scraper.get_office_list
31
39
  puts "Please choose a number from the following list for details on
@@ -35,7 +43,7 @@ class Urgentcare::CLI
35
43
  puts "#{i + 1}. #{office.name}"
36
44
  end
37
45
  list
38
- end
46
+ end
39
47
 
40
48
  def list
41
49
  puts " "
@@ -46,6 +54,7 @@ class Urgentcare::CLI
46
54
  location = location.to_i
47
55
  $index = location - 1
48
56
  loading_message
57
+ @scraper.get_clinic_site
49
58
  office_details
50
59
  else
51
60
  puts "Invalid response"
@@ -60,7 +69,7 @@ class Urgentcare::CLI
60
69
  puts "---"
61
70
  puts "Office Name: #{@offices[$index].name}"
62
71
  puts "Office Number: #{@offices[$index].phone_number}"
63
- puts "Office URL: #{@offices[$index].url}"
72
+ puts "Appointment URL: #{@offices[$index].url}"
64
73
  puts "Office Next Available Appointment: #{@offices[$index].next_available}"
65
74
  puts "---"
66
75
  puts " "
@@ -84,12 +93,4 @@ class Urgentcare::CLI
84
93
  list
85
94
  end
86
95
 
87
- def loading_message
88
- puts " "
89
- puts "Retrieving data...."
90
- puts "Loading......"
91
- puts "............."
92
- puts " "
93
- end
94
-
95
96
  end
@@ -16,7 +16,7 @@ class Urgentcare::Scraper
16
16
  end
17
17
 
18
18
  @@client = Selenium::WebDriver::Remote::Http::Default.new #class variable
19
- @@client.read_timeout = 3000 # seconds – default is 60
19
+ @@client.read_timeout = 6000 # seconds – default is 60
20
20
 
21
21
  @@browser = Watir::Browser.new :chrome, headless: true, http_client: @@client
22
22
  send_cmd(@@browser.driver, "Network.setBlockedURLs", {'urls': ["*careuc.netmng.com*"]}) #url pending when page loads
@@ -32,35 +32,48 @@ class Urgentcare::Scraper
32
32
  end
33
33
 
34
34
  def get_office_list #called first in CLI
35
- @new_page = get_page.css('p')[2..]
35
+ @new_page = get_page.css('div.centers-list')
36
36
  office_url
37
37
  end
38
38
 
39
39
  def office_url
40
40
  @new_page.each do |office_details| #does not create additional objects. returns original object
41
- @@url << office_details
42
41
  @office_details = office_details
43
42
  make_office
44
43
  end
45
44
  end
46
45
 
46
+ def get_clinic_site
47
+ if @@url[$index].url != "Not available"
48
+ @@browser.goto(@@url[$index].url)
49
+ @js_doc = @@browser.iframe.wait_until(&:present?)
50
+ get_appttime_date
51
+ else
52
+ get_appttime_date
53
+ end
54
+ end
55
+
47
56
  def make_office
48
57
  @off = @office.new
49
- @off.name = @office_details.css('a')[0].text
50
- @off.url = @office_details.css('a')[0][name="href"]
51
- @off.phone_number = @office_details.css('a[href]')[1].text
58
+ @off.name = @office_details.css('div.center-name').text
59
+ if @office_details.css('div.center-appointment').css('a').count > 1
60
+ @off.url = @office_details.css('div.center-appointment').css('a[href]')[1].values[1]
61
+ else
62
+ @off.url = "Not available"
63
+ end
64
+ @off.phone_number = @office_details.css('div.center-address').css('a').text
65
+ @@url << @off
52
66
  end
53
67
 
54
68
  def get_appttime_date #retrieve waittime and add to new office model
55
- sleep(1);
56
- iframe_info = Nokogiri::HTML(@js_doc.html)
57
- if !iframe_info.css('div.time-slots').empty?
58
- @wait_day = iframe_info.css('div.d-flex.d-md-none.header').text
59
- @wait_time = iframe_info.css('div.time-slot.selected').text
60
- @office.all[$index].next_available = "#{@wait_day} #{@wait_time}"
61
- else
62
- @wait_time = "Walk-in only due to staffing shortages"
63
- @office.all[$index].next_available = "#{@wait_time}"
69
+ sleep(5);
70
+ if @@url[$index].url != "Not available"
71
+ iframe_info = Nokogiri::HTML(@js_doc.html)
72
+ @wait_day = iframe_info.css('div.calendar').css('div.header').text
73
+ @wait_time = iframe_info.css('div.row').css('div.time-slot')[0].text
74
+ @@url[$index].next_available = "#{@wait_day} #{@wait_time}"
75
+ else
76
+ @@url[$index].next_available = "Not available"
64
77
  end
65
78
  end
66
79
 
@@ -1,3 +1,3 @@
1
1
  module Urgentcare
2
- VERSION = "0.2.5" #increment a version with each release
2
+ VERSION = "0.2.6" #increment a version with each release
3
3
  end #semantic versioning
data/lib/UrgentCare.rb CHANGED
@@ -2,7 +2,7 @@ require 'pry'
2
2
  require 'nokogiri'
3
3
  require 'open-uri'
4
4
  require 'watir'
5
- require 'watir-performance'
5
+ #require 'watir-performance'
6
6
  require 'capybara'
7
7
 
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: UrgentcareCLI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - PamelaTorres-Rocca
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler