qnd_html2page 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/qnd_html2page.rb +6 -5
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a72421b4710f629052f764efd5f2613cb0eadba4f5dc910914794d5fc3b93e8e
|
4
|
+
data.tar.gz: 8ed7eb5ee811967f7ab35954ccac3e50dae8f7e3f8a9853d032087d55b65227d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cca59f8cbe1e762ccf55d8329990cecffd5bdff19e7d221d713c7b1d3feaf57bf9a6b4404b0bcb9ecf571d26746ef1efc27797b56e4a5f4d2f1262c5cf3029c5
|
7
|
+
data.tar.gz: d11b6f38420d004b25c1ead22a59ec2c79ff5af2659cc98c7fda8517f8d4a0011fa087373eb61a401cc239b38e3f79dadd6a86af62dadc398a744d3bce8c18b4
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/qnd_html2page.rb
CHANGED
@@ -41,7 +41,7 @@ class QndHtml2Page
|
|
41
41
|
|
42
42
|
def scan(html)
|
43
43
|
|
44
|
-
# add the span tag after every element in the body
|
44
|
+
# add the span tag after almost every element in the body
|
45
45
|
|
46
46
|
doc = Rexle.new(html)
|
47
47
|
body = doc.root.element('body')
|
@@ -67,14 +67,14 @@ class QndHtml2Page
|
|
67
67
|
File.write tmpfile.path + '.html', doc.root.xml
|
68
68
|
|
69
69
|
browser = Ferrum::Browser.new
|
70
|
-
#browser.resize width: 300, height: 300
|
71
70
|
browser.goto('file://' + tmpfile.path + '.html')
|
72
|
-
browser.screenshot(path: "/tmp/page.jpg")
|
73
71
|
span_list = browser.xpath('//span')
|
74
72
|
a = span_list.map {|x| [x.text, x.find_position.last] }
|
75
73
|
|
76
74
|
|
77
|
-
heights = ((a.last.last) / @height).round.to_i.times
|
75
|
+
heights = ((a.last.last) / @height).round.to_i.times\
|
76
|
+
.inject([@height]) {|r, x| r << (r.last + @height) }
|
77
|
+
|
78
78
|
puts ('heights: ' + heights.inspect).debug if @debug
|
79
79
|
height = heights.shift
|
80
80
|
|
@@ -106,7 +106,8 @@ class QndHtml2Page
|
|
106
106
|
pages = elements.slice_at(*stops).map do |e_list|
|
107
107
|
|
108
108
|
div = Rexle::Element.new 'div'
|
109
|
-
e_list.reject! {|e| e.name == 'span' and
|
109
|
+
e_list.reject! {|e| e.name == 'span' and
|
110
|
+
e.attributes[:class] == 'qndhtml2pg' }
|
110
111
|
next if e_list.empty?
|
111
112
|
e_list.each {|e| div.add e}
|
112
113
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|