Home | Trees | Indices | Help |
|
---|
|
|
|||
|
|
|||
CheckboxGroup Represents a group of checkboxes (<input type=checkbox>) that have the same name. |
|||
CheckboxValues Represents the values of the checked checkboxes in a group of checkboxes with the same name. |
|||
Classes Provides access to an element's class attribute as a set-like collection. Usage: |
|||
FieldsDict | |||
FormElement Represents a <form> element. |
|||
HTMLParser An HTML parser that is configured to return lxml.html Element objects. |
|||
HtmlComment | |||
HtmlElement | |||
HtmlElementClassLookup A lookup scheme for HTML Element classes. |
|||
HtmlEntity | |||
HtmlMixin | |||
HtmlProcessingInstruction | |||
InputElement Represents an <input> element. |
|||
InputGetter An accessor that represents all the input fields in a form. |
|||
InputMixin Mix-in for all input elements (input, select, and textarea) |
|||
LabelElement Represents a <label> element. |
|||
MultipleSelectOptions Represents all the selected options in a <select multiple> element. |
|||
RadioGroup This object represents several <input type=radio> elements that have the same name. |
|||
SelectElement <select> element. You can get the name with .name. |
|||
TextareaElement <textarea> element. You can get the name with .name and get/set the value with .value |
|||
XHTMLParser An XML parser that is configured to return lxml.html Element objects. |
|||
_MethodFunc An object that represents a method on an element as a function; the function takes either an element or an HTML string. It returns whatever the function normally returns, or if the function works in-place (and so returns None) it returns a serialized form of the resulting document. |
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|
|||
XHTML_NAMESPACE =
|
|||
__package__ =
|
|||
_archive_re = re.compile(r'
|
|||
_class_xpath = descendant-or-self::*[@class and contains(conca
|
|||
_collect_string_content = string()
|
|||
_forms_xpath = descendant-or-self::form|descendant-or-self::x:
|
|||
_id_xpath = descendant-or-self::*[@id=$id]
|
|||
_label_xpath = //label[@for=$id]|//x:label[@for=$id]
|
|||
_options_xpath = descendant-or-self::option|descendant-or-self
|
|||
_rel_links_xpath = descendant-or-self::a[@rel]|descendant-or-s
|
|||
find_class = <lxml.html._MethodFunc object>
|
|||
find_rel_links = <lxml.html._MethodFunc object>
|
|||
html_parser = <lxml.html.HTMLParser object>
|
|||
iterlinks = <lxml.html._MethodFunc object>
|
|||
make_links_absolute = <lxml.html._MethodFunc object>
|
|||
resolve_base_href = <lxml.html._MethodFunc object>
|
|||
rewrite_links = <lxml.html._MethodFunc object>
|
|||
xhtml_parser = <lxml.html.XHTMLParser object>
|
|
Create a new HTML Element. This can also be used for XHTML documents. |
Parses a single HTML element; it is an error if there is more than one element, or if anything but whitespace precedes or follows the element. If create_parent is true (or is a tag name) then a parent node will be created to encapsulate the HTML in a single element. In this case, leading or trailing text is also allowed, as are multiple elements as result of the parsing. Passing a base_url will set the document's base_url attribute (and the tree's docinfo.URL). |
Parses several HTML elements, returning a list of elements. The first item in the list may be a string. If no_leading_text is true, then it will be an error if there is leading text, and it will always be a list of only elements. base_url will set the document's base_url attribute (and the tree's docinfo.URL). |
Parse the html, returning a single element/document. This tries to minimally parse the chunk of text, without knowing if it is a fragment or a document. base_url will set the document's base_url attribute (and the tree's docinfo.URL) |
Parse a filename, URL, or file-like object into an HTML document tree. Note: this returns a tree, not an element. Use parse(...).getroot() to get the document root. You can override the base URL with the base_url keyword. This is most useful when parsing from a file-like object. |
Helper function to submit a form. Returns a file-like object, as from urllib.urlopen(). This object also has a .geturl() function, which shows the URL if there were any redirects. You can use this like: form = doc.forms[0] form.inputs['foo'].value = 'bar' # etc response = form.submit() doc = parse(response) doc.make_links_absolute(response.geturl()) To change the HTTP requester, pass a function as open_http keyword argument that opens the URL for you. The function must have the following signature: open_http(method, URL, values) The action is one of 'GET' or 'POST', the URL is the target URL as a string, and the values are a sequence of (name, value) tuples with the form data. |
Return an HTML string representation of the document. Note: if include_meta_content_type is true this will create a <meta http-equiv="Content-Type" ...> tag in the head; regardless of the value of include_meta_content_type any existing <meta http-equiv="Content-Type" ...> tag will be removed The encoding argument controls the output encoding (defauts to ASCII, with &#...; character references for any characters outside of ASCII). Note that you can pass the name 'unicode' as encoding argument to serialise to a Unicode string. The method argument defines the output method. It defaults to 'html', but can also be 'xml' for xhtml output, or 'text' to serialise to plain text without markup. To leave out the tail text of the top-level element that is being serialised, pass with_tail=False. The doctype option allows passing in a plain string that will be serialised before the XML tree. Note that passing in non well-formed content here will make the XML output non well-formed. Also, an existing doctype in the document tree will not be removed when serialising an ElementTree instance. Example: >>> from lxml import html >>> root = html.fragment_fromstring('<p>Hello<br>world!</p>') >>> html.tostring(root) '<p>Hello<br>world!</p>' >>> html.tostring(root, method='html') '<p>Hello<br>world!</p>' >>> html.tostring(root, method='xml') '<p>Hello<br/>world!</p>' >>> html.tostring(root, method='text') 'Helloworld!' >>> html.tostring(root, method='text', encoding='unicode') u'Helloworld!' >>> root = html.fragment_fromstring('<div><p>Hello<br>world!</p>TAIL</div>') >>> html.tostring(root[0], method='text', encoding='unicode') u'Helloworld!TAIL' >>> html.tostring(root[0], method='text', encoding='unicode', with_tail=False) u'Helloworld!' >>> doc = html.document_fromstring('<p>Hello<br>world!</p>') >>> html.tostring(doc, method='html', encoding='unicode') u'<html><body><p>Hello<br>world!</p></body></html>' >>> print(html.tostring(doc, method='html', encoding='unicode', ... doctype='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"' ... ' "http://www.w3.org/TR/html4/strict.dtd">')) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><body><p>Hello<br>world!</p></body></html> |
|
_class_xpath
|
_forms_xpath
|
_options_xpath
|
_rel_links_xpath
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Sep 9 15:24:18 2018 | http://epydoc.sourceforge.net |