structs
This commit is contained in:
parent
450a253213
commit
fe35b44aa5
40
scrap.nim
40
scrap.nim
@ -2,24 +2,52 @@ import std/htmlparser
|
|||||||
import std/xmltree
|
import std/xmltree
|
||||||
import std/strtabs
|
import std/strtabs
|
||||||
|
|
||||||
|
type
|
||||||
|
Descriptor = object
|
||||||
|
name : string
|
||||||
|
html_tag : string
|
||||||
|
html_context_tag : string
|
||||||
|
contains_string : string
|
||||||
|
attrs : string
|
||||||
type
|
type
|
||||||
Entry = object
|
Entry = object
|
||||||
name, tag, description, link, category : string
|
name, tag, description, link, category : Descriptor
|
||||||
|
|
||||||
|
proc setDescriptor(desc : var Descriptor, descToChange : string, value : string) =
|
||||||
|
case descToChange:
|
||||||
|
of "name":
|
||||||
|
desc.name = value
|
||||||
|
of "html_tag":
|
||||||
|
desc.html_tag = value
|
||||||
|
of "html_context_tag":
|
||||||
|
desc.html_context_tag = value
|
||||||
|
of "contains_string":
|
||||||
|
desc.contains_string = value
|
||||||
|
of "attrs":
|
||||||
|
desc.attrs = value
|
||||||
|
|
||||||
|
|
||||||
|
#proc newEntry() : Entry =
|
||||||
|
# newDescriptor()
|
||||||
|
|
||||||
proc getEntryFromHtml(entry : Entry, node : XmlNode) =
|
proc getEntryFromHtml(entry : Entry, node : XmlNode) =
|
||||||
echo(entry.description)
|
echo(entry.description)
|
||||||
|
var childrens = node.findAll(entry.name.html_tag)
|
||||||
|
|
||||||
|
|
||||||
proc test() =
|
proc test() =
|
||||||
var htmlnode : XmlNode
|
var htmlnode : XmlNode
|
||||||
var str_html : string
|
var str_html : string
|
||||||
var entry: Entry
|
var entry: Entry
|
||||||
|
# entry = Entry(name : "testname",description : "testdescription",link : "testlink",category : "testcategory")
|
||||||
|
entry.name.setDescriptor("name","testname")
|
||||||
entry = Entry(name : "testname",description : "testdescription",link : "testlink",category : "testcategory")
|
entry.name.setDescriptor("html_tag","p")
|
||||||
|
entry.link.setDescriptor("name","inserat_link")
|
||||||
|
entry.link.setDescriptor("html_tag","a")
|
||||||
|
entry.link.setDescriptor("attrs","href")
|
||||||
|
echo entry
|
||||||
|
|
||||||
htmlnode = parseHtml(str_html)
|
htmlnode = parseHtml(str_html)
|
||||||
entry.getEntryFromHtml()
|
#entry.getEntryFromHtml()
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
Loading…
Reference in New Issue
Block a user