page_by_page 0.1.2 → 0.1.3
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/version.rb +1 -1
- data/lib/page_by_page.rb +18 -2
- 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: 8f4ae9437d8b93ffeae964877df913939a700cfa
|
4
|
+
data.tar.gz: 79f64e3d36c7b982aa5bbe2c92222520c83f03ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65519fdc3814f678b812fa85b7d298352a68a95f998e8eb8a0fd5c1ba775ee192e15d08957639147fa5803691764e9015a7d9d99c55d4f49256bb720988dfb4f
|
7
|
+
data.tar.gz: d5025ffd44d32a089c7f709ffebf8af59f4c29cc77a60f2f257d02f5bf2123da6a78b2e807aedd5dd95aa22f7428dd2d4aa8a8789b2b10cb6c2facaeb6afa728
|
data/lib/page_by_page/version.rb
CHANGED
data/lib/page_by_page.rb
CHANGED
@@ -17,18 +17,27 @@ class PageByPage
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def url tmpl
|
20
|
-
@
|
20
|
+
@tmpl = tmpl
|
21
21
|
end
|
22
22
|
|
23
23
|
def selector sl
|
24
24
|
@selector = sl
|
25
25
|
end
|
26
26
|
|
27
|
+
def from n
|
28
|
+
@from = n
|
29
|
+
end
|
30
|
+
|
31
|
+
def step n
|
32
|
+
@step = n
|
33
|
+
end
|
34
|
+
|
27
35
|
def fetch
|
36
|
+
url = Url.new @tmpl, options
|
28
37
|
items, all_items = [nil], []
|
29
38
|
catch :no_more do
|
30
39
|
until items.empty?
|
31
|
-
doc = parse
|
40
|
+
doc = parse url.next
|
32
41
|
items = doc.css @selector
|
33
42
|
all_items << items
|
34
43
|
end
|
@@ -48,4 +57,11 @@ class PageByPage
|
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
60
|
+
def options
|
61
|
+
opt = {}
|
62
|
+
opt[:from] = @from || 1
|
63
|
+
opt[:step] = @step || 1
|
64
|
+
opt
|
65
|
+
end
|
66
|
+
|
51
67
|
end
|