{ "info": { "author": "Taras Gaidukov", "author_email": "kemaweyan@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "=========================================================================\n EasyHTML :: A package that provides an easy access to elements\n of HTML and XHTML documents through the Document Object Model.\n=========================================================================\n\nHomepage: http://easyhtml.sourceforge.net/\n\nAuthor: Taras Gaidukov\n\n================================\n Installation Instructions:\n================================\n\nDependencies:\n\n Python 3.4+\n\nBuild and install by running:\n\n $ python setup.py build\n $ sudo python setup.py install\n\n============\n Overview:\n============\n\nThe package contains a module easyhtml.parser that provides a class\neasyhtml.parser.DOMParser (a subclass of html.parser.HTMLParser).\nThis class has a method get_dom() that returns a DOM of parsed document\nwhich is an instance of easyhtml.dom.HTMLDocument class:\n\nfrom easyhtml import parser\n\ndom_parser = parser.DOMParser()\ndom_parser.feed(''\n '
'\n 'First paragraph
'\n 'Second paragraph
'\n 'Third paragraph
'\n 'tags in each one.\n\nCollection {\n Collection {\n
\n }\n Collection {\n
\n
\n }\n}\n\nSuch behavior is similar to that the use of the collection in the for-loop and\nmaking new search requests to each element separately:\n\ncollection = document.get_tags_by_name('div')\nfor element in collection:\n sub_collection = element.get_tags_by_name('p')\n # do something with found tags\n\nThe same result would be if you call a new search request to the collection\ndirectly and use the result in the for-loop:\n\ncollection = document.get_tags_by_name('div')\ncollection = collection.get_tags_by_name('p')\nfor sub_collection in collection:\n # do something with found tags\n\nOr even shorter:\n\nfor sub_collection in document.div.p:\n # do something with found tags\n\nPlease note that the get_element_by_id() method returns a single tag as well\nas HTMLTag and HTMLDocument objects do, since it's assumed that the id is\nunique and there is only one tag with such id in the document even if the\nhierarhy of its elements has been destroyed.\n\nIn addition the HTMLCollection class provides a method that helps to refine \nthe request:\n\nfilter_tags_by_attrs(query) - filters found elements by specified query\n\nAlso this method is implemented as the magic method __call__, so it's possible\nto filter tags using simplier syntax with brackets:\n\ndocument.div(class=someclass) # returns a collection of div elements with\n # the class \"someclass\"\n\nNote that the filter_tags_by_attrs() method does not create a new level of\nnested collections.\n\n===========================\n Package API reference:\n===========================\n\nclass easyhtml.parser.DOMParser()\n\n Creates a parser instance. The DOMParser is a subclass of\n html.parser.HTMLParser class. For more details about HTMLParser usage see\n the official documentation of HTMLParser at Python's website.\n\nDOMParser Methods:\n\nDOMParser.get_dom()\n\n Returns an instance of HTMLDocument that is the root object of the\n Document Object Model.\n\n\nclass easyhtml.dom.DoctypeDeclaration(decl)\n\n A doctype declaration of the document. Used as an attribute of\n easyhtml.dom.HTMLDocument objects. Is not visible in the str version of\n the document, but it's present in the HTML code.\n\n :decl: the text of the declaration, type str\n\nDoctypeDeclaration Methods:\n\nDoctypeDeclaration.raw_html\n\n A property that returns a raw HTML code of the declaration. It consists of\n the text passed into constructor between symbols. For instance,\n \n\nDoctypeDeclaration.__str__()\n\n Returns a str version of the declaration. It's implicitly called in the\n str context. Always returns an empty string since the doctype declaration\n is invisible on the page.\n\n\nclass easyhtml.dom.HTMLComment(text)\n\n A comment in the HTML code. It's not visible in the str version of the\n document, but it's present in the HTML code.\n\n :text: a text of the comment, type str\n\nHTMLComment Methods:\n\nHTMLComment.raw_html\n\n A property that returns a raw HTML code of the comment. It consists of the\n text passed into constructor between symbols. For instance,\n \n\nHTMLComment.__str__()\n\n Returns a str version of the comment. It's implicitly called in the str\n context. Always returns an empty string since comments are invisible on\n the page.\n\n\nclass easyhtml.dom.TextNode()\n\n A text data element in the document. It's a container for any visible\n text data on the page. Could contain PlainText, NamedEntity and\n NumEntity objects.\n\nTextNode Methods:\n\nTextNode.raw_html\n\n A property that returns a raw HTML code of all contained objects.\n\nTextNode.__str__()\n\n Returns a str version of the text data. It's implicitly called in the str\n context. Includes corresponding characters instead of contained HTML\n entities.\n\nTextNode.append(element)\n\n Adds an element to the end of the list.\n\n :element: an element to append, type easyhtml.dom.HTMLText (a superclass\n of PlainText, NamedEntity and NumEntity classes.\n\n\nclass easyhtml.dom.PlainText(text)\n\n A plain text on the page (without HTML entities). It's used inside of the\n TextNode element only.\n\n :text: a text of the element, type str\n\nPlainText Methods:\n\nPlainText.raw_html\n\n A property that returns all characters of the text as it is in the HTML\n document.\n\nPlainText.__str__()\n\n Returns a str version of the text. It's implicitly called in the str\n context. Replaces sequences of white space characters with single spaces.\n\n\nclass easyhtml.dom.NamedEntity(name)\n\n A named HTML entity. It's used inside of the TextNode element only. If the\n entity with specified name does not exist, the KeyError would be rised.\n\n :name: a name of the entity, type str\n\nNamedEntity Methods:\n\nNamedEntity.raw_html\n\n A property that returns an HTML code of the entity. It consists of the\n name passed into constructor between & and ; symbols.\n\nNamedEntity.__str__()\n\n Returns a str version of the entity. It's implicitly called in the str\n context. For instance, it returns the \"<\" character for the entity with\n the code <\n\n\nclass easyhtml.dom.NumEntity(num)\n\n A numeric HTML entity specified by decimal or hexadecimal code. It's used\n inside of the TextNode element only. If the entity with specified numeric\n code does not exist, the KeyError would be rised.\n\n :num: a numeric code of the entity, type str\n\nNamedEntity Methods:\n\nNamedEntity.raw_html\n\n A property that returns an HTML code of the entity. It consists of the\n name passed into constructor between and ; symbols.\n\nNamedEntity.__str__()\n\n Returns a str version of the entity. It's implicitly called in the str\n context. For instance, it returns the \"<\" character for the entity with\n the code < or <\n\n\nclass HTMLTag(name, attrs)\n\n An HTML tag. Could be single such as
or complex such as
...
.\n Complex tags could contain other elements (TextNode, HTMLComment or\n HTMLTag).\n\n :name: a name of the tag, type str\n :attrs: a list of tuples with attributes of the tag,\n format [(attr1, value1), (attr2: value2)]\n\nHTMLTag Methods:\n\nHTMLTag.single\n\n Aproperty that indicates whether the tag is single, i.e. does not require\n an endtag. The result depends on the name of the tag: there is a list of\n the single tags and if the name matches any item from the list, the tag is\n considered as single.\n\nHTMLTag.raw_html\n\n A property that returns an HTML code of the tag. It consists of the\n start tag, inner HTML code and the end tag.\n\nHTMLTag.__str__()\n\n Returns a str version of the tag. It's implicitly called in the str\n context. It consists of the str versions of all contained elements.\n For instance, it returns \"Hello, world!\" for the tag\nHello, world!
\n\nHTMLTag.start_tag\n\n A property that returns an HTML code of the start tag. It consists of the\n name and attributes of the tag in the angle brackets:\n