Viewing File: /usr/lib64/python2.7/site-packages/lxml/html/soupparser.pyo
ó
ÕöePc @ s d Z d d d g Z d d l m Z m Z d d l m Z m Z m Z m Z m Z d d d „ Z d d d „ Z d d „ Z
d
„ Z d „ Z d „ Z d
„ Z y d d l m Z Wn! e k
rØ d d l m Z n Xd d l Z e j d ƒ j Z d „ Z d S( s5 External interface to the BeautifulSoup HTML parser.
t
fromstringt parset convert_treeiÿÿÿÿ( t etreet html( t
BeautifulSoupt Tagt Commentt ProcessingInstructiont NavigableStringc K s t | | | | S( s¤ Parse a string of HTML data into an Element tree using the
BeautifulSoup parser.
Returns the root ``<html>`` Element of the tree.
You can pass a different BeautifulSoup parser through the
`beautifulsoup` keyword, and a diffent Element factory function
through the `makeelement` keyword. By default, the standard
``BeautifulSoup`` class and the default factory of `lxml.html` are
used.
( t _parse( t datat
beautifulsoupt makeelementt bsargs( ( s: /usr/lib64/python2.7/site-packages/lxml/html/soupparser.pyR s c K s@ t | d ƒ s t | ƒ } n t | | | | } t j | ƒ S( sY Parse a file into an ElemenTree using the BeautifulSoup parser.
You can pass a different BeautifulSoup parser through the
`beautifulsoup` keyword, and a diffent Element factory function
through the `makeelement` keyword. By default, the standard
``BeautifulSoup`` class and the default factory of `lxml.html` are
used.
t read( t hasattrt openR
R t ElementTree( t fileR R
R t root( ( s: /usr/lib64/python2.7/site-packages/lxml/html/soupparser.pyR s c C sX | d k r t j j } n t | | ƒ } | j ƒ } x | D] } | j | ƒ q= W| S( s Convert a BeautifulSoup tree to a list of Element trees.
Returns a list instead of a single root Element to support
HTML-like soup with more than one root element.
You can pass a different Element factory through the `makeelement`
keyword.
N( t NoneR t html_parserR
t
_convert_treet getchildrent remove( t beautiful_soup_treeR
R t childrent child( ( s: /usr/lib64/python2.7/site-packages/lxml/html/soupparser.pyR ' s
c K s¡ | d k r t } n | d k r0 t j j } n d | k rI d | d <n | | | } t | | ƒ } t | ƒ d k r” | d j d k r” | d Sd | _ | S( Nt convertEntitiesR i i ( R R R R R
R t lent tag( t sourceR R
R t treeR ( ( s: /usr/lib64/python2.7/site-packages/lxml/html/soupparser.pyR
; s
% c C s2 | | j d t | j ƒ ƒ} t | | | ƒ | S( Nt attrib( t namet dictt attrst _convert_children( R R
R ( ( s: /usr/lib64/python2.7/site-packages/lxml/html/soupparser.pyR J s c C s) t j } d } x| D]} t | t ƒ r„ | | | j d t g | j D] \ } } | t | ƒ f ^ qG ƒ ƒ} t | | | ƒ q t
| ƒ t k r¯ t | | t | ƒ ƒ q t | t
ƒ r× | j t j
| ƒ ƒ q t | t ƒ r| j t j | j d d ƒ Œ ƒ q t | | t | ƒ ƒ q Wd S( NR"