29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/oddb2xml/chapter_70_hack.rb', line 29
def self.parse(html_file = 'http://bag.e-mediat.net/Sl2007.web.external/varia_De.htm')
data = Hash.new{|h,k| h[k] = [] }
Ox.default_options = {
mode: :generic,
effort: :tolerant,
smart: true
}
res = Ox.load(open(html_file).read, mode: :hash_no_attrs).values.first['body']
result = []
idx = 0
@@items = {}
res.values.last.each do |item|
item.values.first.each do |subElem|
what = Chapter70xtractor.parse_td(subElem)
idx += 1
puts "#{idx}: xx #{what}" if $VERBOSE
result << what
end
end
result2 = result.find_all{ |x| (x.is_a?(Array) && x.first.is_a?(String)) && x.first.to_i > 100}
result2.each do |entry|
data = {}
pharma_code = entry.first
ean13 = (Oddb2xml::FAKE_GTIN_START + pharma_code.to_s)
german = entry[2].force_encoding('ISO-8859-1').encode('UTF-8')
while !german.eql?(HTMLEntities.new.decode(german))
german = HTMLEntities.new.decode(german)
end
@@items[ean13] = {
:data_origin => 'Chapter70',
:line => entry.join(","),
:ean13 => ean13,
:description => Oddb2xml.html_decode(entry[2]),
:quantity => entry[3],
:pharmacode => pharma_code,
:pub_price => entry[4],
:limitation => entry[5],
:type => :pharma,
}
end
result2
end
|