nypl-site-scraper 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/lib/nypl_site_scraper/scraper.rb +36 -22
- data/lib/nypl_site_scraper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae38c0466638a3e6bea2d077b6b774962bd81d05
|
4
|
+
data.tar.gz: 5481b0384d607e5f64522526f721fd69c701ee12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3beb836976fd317d1146c17d5d2c493b2455d00a7b77c454632e68cdac7e2454ad69dc642b984855cc281e3427b7579730e7cd43494c5312dc129fa1e1529ef2
|
7
|
+
data.tar.gz: 1acfeeb135cfc3d108916b538a7f365affe0f6457d8ffa6cde291ce992a7b2dc595653b569f31249af5600e9f27871f6661177a9e565aa648a3e4a78c08d3533
|
data/README.md
CHANGED
@@ -37,10 +37,13 @@ client = NyplSiteScraper::Client.new(barcode: '11111111111111', pin: '2222')
|
|
37
37
|
client.login! # This is the network call
|
38
38
|
|
39
39
|
client.get_holds
|
40
|
-
|
40
|
+
# {"holds"=>[{"title"=>"Persepolis. English", "statusString"=>"READY FOR PICKUP", "status"=>"ready", "pickupLocation"=>"Mid-Manhattan Library at 42nd St"}...
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
client.get_fines
|
43
|
+
#{:fines=>[{:title=>"Zog and the flying doctors / by Julia Donaldson & illustrated by Axel Scheffler.", :fineAmount=>"$0.20"}...
|
44
|
+
|
45
|
+
client.get_checkouts
|
46
|
+
# {:checkouts => [{:title "Foo", dueDate: "Some date"}]}
|
44
47
|
```
|
45
48
|
|
46
49
|
## Development
|
@@ -20,6 +20,21 @@ module NyplSiteScraper
|
|
20
20
|
true
|
21
21
|
end
|
22
22
|
|
23
|
+
def get_checkouts
|
24
|
+
@check_outs_page ||= @homepage.link_with(text: "My Checked Out Items").click
|
25
|
+
check_cout_rows = @check_outs_page.search('tr.patFuncEntry')
|
26
|
+
|
27
|
+
check_outs_response = []
|
28
|
+
check_cout_rows.each do |check_out_row|
|
29
|
+
check_outs_response << {
|
30
|
+
title: check_out_row.search('td.patFuncTitle').text.strip,
|
31
|
+
dueDate: check_out_row.search('td.patFuncStatus').text.strip
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
{checkouts: check_outs_response}
|
36
|
+
end
|
37
|
+
|
23
38
|
def get_fines
|
24
39
|
@fines_page ||= @agent.get("https://catalog.nypl.org/patroninfo~S1/thisurlsegment-doesnt-seem-to-matter-hahahah/overdues")
|
25
40
|
fines_rows = @fines_page.search('tr.patFuncFinesEntryTitle')
|
@@ -54,31 +69,30 @@ module NyplSiteScraper
|
|
54
69
|
{holds: response_holds}
|
55
70
|
end
|
56
71
|
|
57
|
-
|
72
|
+
private
|
58
73
|
|
59
|
-
|
74
|
+
def map_status_string(status_string)
|
60
75
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
76
|
+
if status_string == "READY FOR PICKUP"
|
77
|
+
return "ready"
|
78
|
+
elsif status_string == "IN TRANSIT"
|
79
|
+
return "in transit"
|
80
|
+
elsif status_string.include?('of')
|
81
|
+
return "pending"
|
82
|
+
else
|
83
|
+
return status_string
|
84
|
+
end
|
85
|
+
end
|
71
86
|
|
72
|
-
# Helper because markup for pending vs ready is different
|
73
|
-
def get_pickup_location(row)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
87
|
+
# Helper because markup for pending vs ready is different
|
88
|
+
def get_pickup_location(row)
|
89
|
+
pickUpCell = row.css('td.patFuncPickup')
|
90
|
+
if pickUpCell.search('div.patFuncPickupLabel').length > 0
|
91
|
+
row.css('td.patFuncPickup option[selected=selected]').first.text.strip
|
92
|
+
else
|
93
|
+
pickUpCell.text.strip
|
94
|
+
end
|
95
|
+
end
|
82
96
|
|
83
97
|
end
|
84
98
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nypl-site-scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nodanaonlyzuul
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|