import leaf document = leaf.parse(sample) links = document ( 'div#menu a' ) # CSS link = document .get( 'div#menu a' ) # None ( ) * This source code was highlighted with Source Code Highlighter .
import leaf document = leaf.parse(sample) links = document ( 'div#menu a' ) # CSS link = document .get( 'div#menu a' ) # None ( ) * This source code was highlighted with Source Code Highlighter .
import leaf document = leaf.parse(sample) links = document ( 'div#menu a' ) # CSS link = document .get( 'div#menu a' ) # None ( ) * This source code was highlighted with Source Code Highlighter .
import leaf document = leaf.parse(sample) links = document ( 'div#menu a' ) # CSS link = document .get( 'div#menu a' ) # None ( ) * This source code was highlighted with Source Code Highlighter .
import leaf document = leaf.parse(sample) links = document ( 'div#menu a' ) # CSS link = document .get( 'div#menu a' ) # None ( ) * This source code was highlighted with Source Code Highlighter .
import leaf document = leaf.parse(sample) links = document ( 'div#menu a' ) # CSS link = document .get( 'div#menu a' ) # None ( ) * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- print link.onclick
- print link.id
* This source code was highlighted with Source Code Highlighter .
- link = document .xpath ( 'body / div / ul / li [@ class = "active_link"]' ) [0]
- link.get ( 'a' ) .text
* This source code was highlighted with Source Code Highlighter .
- # An example of the function of the converter from html to some
- # markup language that supports only
- # links enclosed in [url] [/ url]
- def omgcode_formatter (element, children):
- # Replace <br> with a newline character
- if element.tag == 'br' :
- return '\ n'
- # We put links in [url] [/ url]
- if element.tag == 'a' :
- return u "[url = link}] {text} [/ url]" .format (link = element.href, text = children)
- # For all other elements we return the result.
- # processing all children.
- if children:
- return children
* This source code was highlighted with Source Code Highlighter .
- document .parse (omgcode_formatter)
Source: https://habr.com/ru/post/115135/
All Articles