diff --git a/main b/main index 76fe68c..cc28230 100755 Binary files a/main and b/main differ diff --git a/main.nim b/main.nim index 6f1f817..4138424 100644 --- a/main.nim +++ b/main.nim @@ -21,7 +21,7 @@ try: var entry : Entry 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:"key_and_string_search",contains_string: "a",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")) diff --git a/scrap.nim b/scrap.nim index f35bc4a..cdb6589 100644 --- a/scrap.nim +++ b/scrap.nim @@ -1,6 +1,7 @@ import std/htmlparser import std/xmltree import std/strtabs +import std/strutils type Descriptor* = object @@ -20,13 +21,14 @@ proc getEntryFromHtml*(entry : Entry, node : XmlNode) = 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) + echo("found key [",entry.desc[i].attrs,"] in : ",b) if entry.desc[i].contains_string != "": - echo(" and string: ",b) - #check if b contains contains_string + let content_txt = b.innerText() + echo(" and string(innerText): ",content_txt) + if content_txt.contains(entry.desc[i].contains_string): + echo("PATTERN MATCH") #return function if entry.desc[i].contains_string != "": echo("found string: ",b)