mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Improve tweet selectors
This commit is contained in:
parent
02fcd7b880
commit
7d2fa15676
2 changed files with 12 additions and 7 deletions
|
|
@ -16,6 +16,11 @@ proc select*(node: XmlNode; selector: string): XmlNode =
|
|||
let nodes = node.selectAll(selector)
|
||||
if nodes.len > 0: nodes[0] else: nil
|
||||
|
||||
proc select*(node: XmlNode; parent, child: string): XmlNode =
|
||||
let parentNode = node.select(parent)
|
||||
if parentNode.isNil(): return
|
||||
result = parentNode.select(child)
|
||||
|
||||
proc getAttr*(node: XmlNode; attr: string; default=""): string =
|
||||
if node.isNil or node.attrs.isNil: return default
|
||||
return node.attrs.getOrDefault(attr)
|
||||
|
|
|
|||
Loading…
Reference in a new issue