page_by_page 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/page_by_page.rb +12 -4
- data/lib/page_by_page/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa944dd4b26a3928521fab9ab0715912b5b41da
|
4
|
+
data.tar.gz: ec53a56c45380b0a95994ab056bbf1d0e33b2fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea009729e29a8bd6922992d9afcddec3dfe5cf1dc9003cbae7bb24e1c1c2a8b4fddd521adf7f879d298a25431db18ae8f8fbf22bd6b382a90244ad385d298c5a
|
7
|
+
data.tar.gz: 254f829aa7fc8b08e280c00f0c640c96740893e6f8c564403a0b9b2d50f03465318739ecb383f650c71104adbbe3a2fdb6389832a28ed312f74479ee45771c40
|
data/lib/page_by_page.rb
CHANGED
@@ -26,10 +26,12 @@ class PageByPage
|
|
26
26
|
|
27
27
|
def fetch
|
28
28
|
items, all_items = [nil], []
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
catch :no_more do
|
30
|
+
until items.empty?
|
31
|
+
doc = parse @url.next
|
32
|
+
items = doc.css @selector
|
33
|
+
all_items << items
|
34
|
+
end
|
33
35
|
end
|
34
36
|
all_items.flatten
|
35
37
|
end
|
@@ -38,6 +40,12 @@ class PageByPage
|
|
38
40
|
|
39
41
|
def parse url
|
40
42
|
Nokogiri::HTML open url
|
43
|
+
rescue OpenURI::HTTPError => e
|
44
|
+
if e.message == '404 Not Found'
|
45
|
+
throw :no_more
|
46
|
+
else
|
47
|
+
raise e
|
48
|
+
end
|
41
49
|
end
|
42
50
|
|
43
51
|
end
|
data/lib/page_by_page/version.rb
CHANGED