This commit is contained in:
2024-07-01 13:49:39 +02:00
parent 4d2b868b76
commit 605480dbfd
3 changed files with 28 additions and 6 deletions

View File

@@ -8,6 +8,8 @@ type
name* : string
html_tag* : string
html_context_tag* : string
html_context_attrs* : string
html_context_key* : string
contains_string* : string
attrs* : string
content* : seq[string]
@@ -16,9 +18,31 @@ type
desc* : seq[Descriptor]
proc getEntryFromHtml*(entry :var Entry, node : XmlNode) : Entry =
var
context : seq[XmlNode]
tmpContext : seq[XmlNode]
for i,desc in entry.desc:
context = @[] #clear sequences
tmpContext = @[]
echo("descriptor ",i," content: ",entry.desc[i])
let context = node.findAll(entry.desc[i].html_context_tag)
#filter context
if entry.desc[i].html_context_attrs == "":
context = node.findAll(entry.desc[i].html_context_tag)
else:
tmpContext = node.findAll(entry.desc[i].html_context_tag)
#filter by attributes
for i3,c in tmpContext:
echo("c: ",c.attrs, "i3: ", i3, "i: ", i, "len tmpContext: ",tmpContext.len())
if c.attrs.hasKey(entry.desc[i].html_context_attrs):
echo("HAS-Context_KEY: ",c.attrs)
if entry.desc[i].html_context_key != "":
if c.attrs[entry.desc[i].html_context_attrs] == entry.desc[i].html_context_key:
context.add(c)
echo("key_MATCH")
else:
context.add(c)
echo("out of for loop")
#end filter context
for a in context:
let subContext = a.findAll(entry.desc[0].html_tag)
for b in subContext:
@@ -34,7 +58,6 @@ proc getEntryFromHtml*(entry :var Entry, node : XmlNode) : Entry =
entry.desc[i].content.add(content_txt)
else:
entry.desc[i].content.add(b.attrs[entry.desc[i].attrs])
elif entry.desc[i].contains_string != "":
var content_txt = b.innerText()
echo(" string(innerText): ",content_txt)