sequence iterate description
This commit is contained in:
parent
6159f5d218
commit
b782ea43f2
7
main.nim
7
main.nim
@ -20,8 +20,11 @@ try:
|
||||
var htmlnode: XmlNode
|
||||
var entry : Entry
|
||||
|
||||
add(entry.name,Descriptor(name : "alink", html_context_tag : "div", html_tag : "a",attrs : "href"))
|
||||
add(entry.name,Descriptor(name:"anotherlin",html_context_tag : "div", html_tag : "a",attrs : "href"))
|
||||
add(entry.desc,Descriptor(name : "alink", html_context_tag : "div", html_tag : "a",attrs : "href"))
|
||||
add(entry.desc,Descriptor(name:"anotherlin",html_context_tag : "div", html_tag : "a",attrs : "href"))
|
||||
add(entry.desc,Descriptor(name:"anotherlin",html_context_tag : "div", html_tag : "a",attrs : "href"))
|
||||
add(entry.desc,Descriptor(name:"anotherlin",html_context_tag : "didfgv", html_tag : "sdfga",attrs : "hdsfgref"))
|
||||
|
||||
echo entry
|
||||
entry.getEntryFromHtml(node)
|
||||
# echo node
|
||||
|
41
scrap.nim
41
scrap.nim
@ -11,35 +11,34 @@ type
|
||||
attrs* : string
|
||||
type
|
||||
Entry* = object
|
||||
name* : seq[Descriptor]
|
||||
desc* : seq[Descriptor]
|
||||
|
||||
proc getEntryFromHtml*(entry : Entry, node : XmlNode) =
|
||||
echo(entry.name[0])
|
||||
|
||||
let context = node.findAll(entry.name[0].html_context_tag)
|
||||
for a in context:
|
||||
|
||||
let subContext = a.findAll(entry.name[0].html_tag)
|
||||
for b in subContext:
|
||||
echo(b)
|
||||
if entry.name[0].attrs != "":
|
||||
if b.attrs.hasKey(entry.name[0].attrs):
|
||||
echo("found key")
|
||||
if entry.name[0].contains_string != "":
|
||||
echo(" and string")
|
||||
#check if b contains contains_string
|
||||
#return function
|
||||
if entry.name[0].contains_string != "":
|
||||
echo("found string")
|
||||
#check if b contains contains_string
|
||||
#return function
|
||||
for i,desc in entry.desc:
|
||||
echo("descriptor ",i," content: ",entry.desc[i])
|
||||
let context = node.findAll(entry.desc[i].html_context_tag)
|
||||
for a in context:
|
||||
let subContext = a.findAll(entry.desc[0].html_tag)
|
||||
for b in subContext:
|
||||
echo(b)
|
||||
if entry.desc[i].attrs != "":
|
||||
if b.attrs.hasKey(entry.desc[i].attrs):
|
||||
echo("found key: ",entry.desc[i].attrs)
|
||||
if entry.desc[i].contains_string != "":
|
||||
echo(" and string: ",b)
|
||||
#check if b contains contains_string
|
||||
#return function
|
||||
if entry.desc[i].contains_string != "":
|
||||
echo("found string: ",b)
|
||||
#check if b contains contains_string
|
||||
#return function
|
||||
|
||||
|
||||
proc test() =
|
||||
var htmlnode : XmlNode
|
||||
var str_html : string
|
||||
var entry: Entry
|
||||
entry.name[0] = Descriptor(html_tag : "p", contains_string : "test_container")
|
||||
entry.desc[0] = Descriptor(html_tag : "p", contains_string : "test_container")
|
||||
echo entry
|
||||
|
||||
htmlnode = parseHtml(str_html)
|
||||
|
Loading…
Reference in New Issue
Block a user