page_by_page 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/page_by_page/version.rb +1 -1
- data/lib/page_by_page.rb +6 -5
- 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: b7b7ac7eab723d81c77692420ccd3fd3e6a69d55
|
4
|
+
data.tar.gz: cfc4977c9d1e3f635e0bc0bded551eb29ee97195
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1840cd52ed71ad5f21c9647a75a9a8630d5df17c6c731e16220d7b8c92361711fe2fdc8eefa2afa458dc106342c133f46c9fde0246e21d6cd0cb7fac279e7be9
|
7
|
+
data.tar.gz: c9625120e03c85610165c6f0b791a9f00ba9939c31c3097371bcd0a0756f62afab99001b976bfbb23beffec977eb3a3158afcffa3e3b383a2c7817c0a84748f1
|
data/README.md
CHANGED
@@ -32,3 +32,16 @@ nodes = PageByPage.fetch do
|
|
32
32
|
end
|
33
33
|
```
|
34
34
|
|
35
|
+
Or just passing parameters:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
nodes = PageByPage.fetch(
|
39
|
+
url: 'https://book.douban.com/subject/25846075/comments/hot?p=<%= n %>',
|
40
|
+
selector: '.comment-item',
|
41
|
+
# from: 2,
|
42
|
+
# step: 2,
|
43
|
+
# to: 100,
|
44
|
+
# threads: 4,
|
45
|
+
# no_progress: true
|
46
|
+
)
|
47
|
+
```
|
data/lib/page_by_page/version.rb
CHANGED
data/lib/page_by_page.rb
CHANGED
@@ -8,16 +8,17 @@ require 'erb'
|
|
8
8
|
class PageByPage
|
9
9
|
|
10
10
|
class << self
|
11
|
-
def fetch &block
|
12
|
-
pbp = self.new &block
|
11
|
+
def fetch(opt ={}, &block)
|
12
|
+
pbp = self.new(opt, &block)
|
13
13
|
pbp.fetch
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def initialize &block
|
17
|
+
def initialize(opt = {}, &block)
|
18
18
|
@from, @step, @to = 1, 1, Float::INFINITY
|
19
19
|
@progress = {}
|
20
|
-
|
20
|
+
opt.each{ |name, value| send name, value }
|
21
|
+
instance_eval &block if block
|
21
22
|
end
|
22
23
|
|
23
24
|
def url tmpl
|
@@ -44,7 +45,7 @@ class PageByPage
|
|
44
45
|
@threads = n
|
45
46
|
end
|
46
47
|
|
47
|
-
def no_progress
|
48
|
+
def no_progress *arg
|
48
49
|
@progress = nil
|
49
50
|
end
|
50
51
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_by_page
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|