sequences
This commit is contained in:
parent
a706754ab4
commit
6159f5d218
5
main.nim
5
main.nim
@ -20,8 +20,9 @@ try:
|
|||||||
var htmlnode: XmlNode
|
var htmlnode: XmlNode
|
||||||
var entry : Entry
|
var entry : Entry
|
||||||
|
|
||||||
entry.name = Descriptor(html_context_tag : "div", html_tag : "a",attrs : "href")
|
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"))
|
||||||
|
echo entry
|
||||||
entry.getEntryFromHtml(node)
|
entry.getEntryFromHtml(node)
|
||||||
# echo node
|
# echo node
|
||||||
# for a in node.findAll("a"):
|
# for a in node.findAll("a"):
|
||||||
|
18
scrap.nim
18
scrap.nim
@ -11,25 +11,25 @@ type
|
|||||||
attrs* : string
|
attrs* : string
|
||||||
type
|
type
|
||||||
Entry* = object
|
Entry* = object
|
||||||
name*, tag*, description*, link*, category* : Descriptor
|
name* : seq[Descriptor]
|
||||||
|
|
||||||
proc getEntryFromHtml*(entry : Entry, node : XmlNode) =
|
proc getEntryFromHtml*(entry : Entry, node : XmlNode) =
|
||||||
echo(entry.description)
|
echo(entry.name[0])
|
||||||
|
|
||||||
let context = node.findAll(entry.name.html_context_tag)
|
let context = node.findAll(entry.name[0].html_context_tag)
|
||||||
for a in context:
|
for a in context:
|
||||||
|
|
||||||
let subContext = a.findAll(entry.name.html_tag)
|
let subContext = a.findAll(entry.name[0].html_tag)
|
||||||
for b in subContext:
|
for b in subContext:
|
||||||
echo(b)
|
echo(b)
|
||||||
if entry.name.attrs != "":
|
if entry.name[0].attrs != "":
|
||||||
if b.attrs.hasKey(entry.name.attrs):
|
if b.attrs.hasKey(entry.name[0].attrs):
|
||||||
echo("found key")
|
echo("found key")
|
||||||
if entry.name.contains_string != "":
|
if entry.name[0].contains_string != "":
|
||||||
echo(" and string")
|
echo(" and string")
|
||||||
#check if b contains contains_string
|
#check if b contains contains_string
|
||||||
#return function
|
#return function
|
||||||
if entry.name.contains_string != "":
|
if entry.name[0].contains_string != "":
|
||||||
echo("found string")
|
echo("found string")
|
||||||
#check if b contains contains_string
|
#check if b contains contains_string
|
||||||
#return function
|
#return function
|
||||||
@ -39,7 +39,7 @@ proc test() =
|
|||||||
var htmlnode : XmlNode
|
var htmlnode : XmlNode
|
||||||
var str_html : string
|
var str_html : string
|
||||||
var entry: Entry
|
var entry: Entry
|
||||||
entry.name = Descriptor(html_tag : "p", contains_string : "test_container")
|
entry.name[0] = Descriptor(html_tag : "p", contains_string : "test_container")
|
||||||
echo entry
|
echo entry
|
||||||
|
|
||||||
htmlnode = parseHtml(str_html)
|
htmlnode = parseHtml(str_html)
|
||||||
|
Loading…
Reference in New Issue
Block a user