File: simple_example.py

package info (click to toggle)
python-selectolax 0.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 708 kB
  • sloc: python: 2,239; makefile: 225
file content (9 lines) | stat: -rw-r--r-- 336 bytes parent folder | download
1
2
3
4
5
6
7
8
9
from selectolax.lexbor import LexborHTMLParser

html = "<div><p id=p1><p id=p2><p id=p3><a>link</a><p id=p4><p id=p5>text<p id=p6></div>"
selector = "div > :nth-child(2n+1):not(:has(a))"

for node in LexborHTMLParser(html).css(selector):
    print(node.attributes, node.text(), node.tag)
    print(node.parent.tag)
    print(node.html)