Saravanan666/pypi-org huggingface dataset:
Package: html2json
Convert a HTML webpage to JSON data using a template defined in JSON.InstallationThis package is available on PyPi. Just usepip install -U html2jsonto install it. Then you can import it usingfrom html2json import collect.APIThe method iscollect(html, template).htmlis the HTML of page loaded as string, andtemplateis the JSON of template loaded as Python objects.Note that the HTML must contain the root node, like<html>...</html>or<div>...</div>.Template SyntaxThe basic syntax iskeyName: [selector, attr, [listOfRegexes]].selectoris a CSS selector (supported bylxml).When the selector isnull, the root node itself is matched.When the selector cannot be matched,nullis returned.attrmatches the attribute value. It can benullto match either the inner text or the outer text when the inner text is empty.The list of regexes[listOfRegexes]supports two forms of regex operations. The operations with in the list are executed sequentially.Replacement:s/regex/replacement/g.gis optional for multiple replacements.Extraction:/regex/.For example:{"Color":["head link:nth-of-type(1)","href",["/\\w+(?=\\.css)/"]],}As JSON, nested structure can be easily constructed.{"Cover":{"URL":[".cover img","src",[]],"Number of Favorites":[".cover .favorites","value",[]]},}An alternative simplified syntaxkeyName: [subRoot, subTemplate]can be used.subRoota CSS selector of the new root for each sub entry.subTemplateis a sub-template for each entry, recursively.For example, the previous example can be simplified as follow.{"Cover":[".cover",{"URL":["img","src",[]],"Number of Favorites":[".favorites","value",[]]}],}To extract a list of sub-entries following the same sub-template, the list syntax iskeyName: [[subRoot, subTemplate]]. Please note the difference (surrounding[and]) from the previous syntax above.subRootis the CSS selector of the new root for each sub entry.subTemplateis the sub-template for each entry, recursively.For example:{"Comments":[[".comments",{"From":[".from",null,[]],"Content":[".content",null,[]],"Photos":[["img",{"URL":["","src",[]]}]]}]]}
Package: html2kirby
This is a html toKirbytextconverter
for python.It is currently in heavy development.InstallationHTML2Kirby is tested and suported from Python 3.4 upwardsInstall via pip:pip install html2kirbyUsageTo use this package, simply import the package and feed it some html:from html2kirby import HTML2Kirby

formatter = HTML2Kirby()
formatter.feed("""<img src="https://placekitten.com/200/300" alt="kittens are cute" />""")You can then access the result via.kirbytextattribute:print(formatter.kirbytext)
# prints (image: https://placekitten.com/200/300 alt: kittesn are cute)TestingMake sure you have Pytest installed (pip install pytest). Then just
invoke it:pytestSupported MarkupAs of now, following tags are supported:Simple formatting (<b>,<strong>,<i>,<em>)Headings (<h1>,<h2>, …)Images (<img>)line breaks (<br>)Paragraphs (<p>)Blocks (<pre>,<code>,<blockquote>,<pre><code>)Links (<a>)Horizontal rulers (<hr>)Lists (<ul>,<ol>,<li>)Passed markupMarkup tags that aren’t implemented are just dropped except for
following tags:tabletrtdthtbodytheadstrikeuabbrdelsvgThey will just be kept in the Kirbytext which should result in a valid
output.IssuesIn python3.4, thedoesn’t quite convert all of the html 5
escaped characters such as – (en dash).
Package: html2mallard
html2mallard / mkdocs-mallardExtremely crude HTML tomallard helpconversion.  Specifically for output frommkdocswith RTD or Material theme.It's a very basic regex extraction (→I'm looking forward to your letters!)
and filtering process.  It only retains some structural elements (headlines,
paragraphs, tables, lists, notes).  Doesn't even attempt to gather any topic
relation/structure from the navigation list.Really just intended for one-time/initial conversion.Requires some editing to get pages to validate.  (Though they probably
"work" in yelp as is).Links and image references certainly require manual cleanup. Nested
lists or tables are likely to cause issues.And API docs are least convertible (only tested mkdocstrings, source
dump is omitted, and there's obviously no syntax colorization in yelp;
alternatively trymkgendocs).Primarily designed for mkdocs´ HTML output.  But also contains some
cleanup rules forfossilwiki pages (withgithubskin),
and yelp-builds` html.Conversion doesn't work well for sphinx output (not consistent enough).html2mallardSimple command line tool to convert a single .html file:html2mallard site/index.html > help/index.pageAdd a-d/--debugflag after the filename for details on the shortening
process.html2mallard in.html --debug | xmllint - --recover > out.pageWithxmllintto fix some unmatched tags.Now also supports http:// urls for conversion:html2mallard http://wiki/index.html > index.pageAnd directly converting from markdown:html2mallard index.md > index.pagemkdocs-mallardConverts a list of mkdocs output files to *.page files.mkdocs-mallardRequires an extramallard_dirin themkdocs.ymlconfig:site_name: logfmt1
docs_dir: docs
site_dir: html
mallard_dir: mallard
use_directory_urls: false
nav:
  - Intro: index.md
theme:
  name: readthedocs
  highlightjs: false
repo_url: https://...
markdown_extensions:
  - admonition
  - codehilite
  - attr_list
  - def_list
  - tables
  - markdown.extensions.codehilite:
      guess_lang: true
plugins:
  - mkdocstringsAlso depends onuse_directory_urls: false, since the script onlyglob()s
one level of*.htmlfiles.Nav linksEnsure theindex.pagecontains a section like:<section id="nav" style="2column">
 <subtitle>Topics</subtitle>
</section>But not the recursive self-reference<link type="guide" xref="index#nav"/>.AdaptionThe first tworewriterules likely require changes for other HTML sources
or templates. Specifically"^.+?</nav>"should strip the initial
boilerplate, else might need expansion. (Either in theGENERAL HTMLor
a new rewrite collection.)fromprojectimportmetametainfodepends-compatPython ≥3.6, mkdocs 1.xcompliancy!pep8, mallard, manpage, !doap, !xdgsystem usage-paths-testing-docs-activityabandonedstatealphasupport-contrib-announce-
Package: html2markdown
ExperimentalPurpose: Converts html to markdown while preserving unsupported html markup. The goal is to generate markdown that can be converted back into html. This is the major difference between html2markdown and html2text. The latter doesn’t purport to be reversible.Usage exampleimport html2markdown
print html2markdown.convert('<h2>Test</h2><pre><code>Here is some code</code></pre>')Output:## Test

    Here is some codeInformation and caveatsDoes not convert the content of block-type tags other than<p>– such as<div>tags – into MarkdownIt does convert to markdown the content of inline-type tags, e.g.<span>.Input:<div>this is stuff.<strong>stuff</strong></div>Result:<div>this is stuff.<strong>stuff</strong></div>Input:<p>this is stuff.<strong>stuff</strong></p>Result:this is stuff. __stuff__(surrounded by a newline on either side)Input:<spanstyle="text-decoration:line-through;">strike<strong>through</strong>sometext</span>hereResult:<spanstyle="text-decoration:line-through;">strike__through__ sometext</span>hereExcept in unprocessed block-type tags, formatting characters are escapedInput:<p>**escapeme?**</p>(in html, we would use <strong> here)Result:\*\*escapeme?\*\*Input:<span>**escapeme?**</span>Result:<span>\*\*escapeme?\*\*</span>Input:<div>**escapeme?**</div>Result:<div>**escapeme?**</div>(block-type)Attributes not supported by Markdown are keptExample:<ahref="http://myaddress"title="clickme"><strong>link</strong></a>Result:[__link__](http://myaddress"click me")Example:<aonclick="javascript:dostuff()"href="http://myaddress"title="clickme"><strong>link</strong></a>Result:<aonclick="javascript:dostuff()"href="http://myaddress"title="clickme">__link__</a>(the attributeonclickis not supported, so the tag is left alone)LimitationsTables are kept as html.Changes0.1.7:Improved handling of inline tags.Fix: Ignore<a>tags without an href attribute.Improve escaping.0.1.6: Added tests and support for Python versions below 2.7.0.1.5: Fix Unicode issue in Python 3.0.1.0: First version.
Package: html2md
html2mdHTML to Markdown converterInstallationpipinstall-Uhtml2mdUsageAs a command line tool:# To convert a file.html2mdexamples/hello.html# To convert from stdin.catexamples/hello.html|html2mdFrom a Python script:importhtml2mdhtml='''<h1>Header</h1><b><i>Hello</i></b> from <code>html2md</code><pre class="py"><code>print('Hello')</code></pre>'''md=html2md.convert(html)print(md)ContributingContributions are welcome! For instructions on how to contribute,
please check theContribution guide.
Package: html2notion
Html2notion简体中文html2notion is an incredibly useful tool written in Python, which allows you to import content from HTML documents into Notion notes, making it more convenient for you to organize information on the Notion platform. In addition, html2notion has been specifically optimized for the content of Evernote, and you can also use it to import notes from Evernote into Notion.html2notion has powerful features and supports converting various tags in HTML files into corresponding Blocks in Notion, such as rich text blocks, headings, images, code blocks, quotes, links, etc. Below are examples of converting notes from Evernote into Notion pages.PrepareYou only need 3 steps to use htmlnotion to import HTML into Notion.Duplicate databaseClick the linknotion template. As shown in the image below, use the "Duplicate" button to copy a new database to your own Notion workspace.Install html2notionRequires python>=3.8, install the html2notion library. You can use the pip command to install it:pip install html2notionPrepare Notion ConfigurationWe need to use theNotion API keyandDatabase IDto authorize html2notion to access the Notion database. Please follow these steps:Create an integration;Share a database with your integration;Export the database ID;When sharing the database here, you need to choose the previously duplicated database because the import operation requires some presetpropertiesinformation in this database.For specific methods, please refer to the Notion official documentationcreate an integration.After the setup is complete, write your API Key and database ID into a configuration file config.json.{"notion":{"database_id":"<***demo***>","api_key":"<***demo***>"}}UsageYou can usehtml2notion -hto view detailed help documentation.usage:html2notion[-h]--confCONF[--logLOG][--batchBATCH](--fileFILE|--dirDIR)Html2notion:SaveHTMLtoyourNotionnotesquicklyandeasily,whilekeepingtheoriginalformatasmuchaspossible

options:-h,--helpshowthishelpmessageandexit--confCONFconffilepath--logLOGlogdirectpath--batchBATCHbatchsaveconcurrentlimit--fileFILESavesinglehtmlfiletonotion--dirDIRSaveallhtmlfilesinthedirtonotionFor example, if you want to import all html files in the./demosdirectory into Notion, you can use the following command:html2notion--confconfig.json--dir./demos--log~/logs--batch10The above command will import all html files in the./demosdirectory into Notion, while outputting logs to the~/logsdirectory, with up to 10 concurrent tasks.More informationYou can find more information and examples in the html2notion library's Issue:html2notionContributionIf you find any errors or have any suggestions for improvement, please do not hesitate to submit a pull request or raise an issue, I am more than happy to accept your contributions and feedback!If you encounter import failures, you can submit the html file and log file together in the issue for easier problem identification.If there are any private information in the files, please remove it first.LicenseThis project uses the MIT license. Please refer to theLICENSEfor details.
Package: html2obj-genwch
Format HTML to python objectSupport xpathSample configep_conf = {"url": "{{video_url}}",
            "root": "{{root}}",
            "items": "//div[@class=\"container\"]/div[2]/div/div[@class=\"myui-panel-bg\"]/div/div[2]/div[@id=\"playlist{{st_cde}}\"]/ul/li[*]/a",
            #    "items": "//div[@class=\"myui-panel-bg\"]/div/div[@class=\"tab-content\"]/div[@id=\"playlist{{st_cde}}\"]/ul/li[*]/a",
            "data": {"root": {"fix": "{{root}}"},
                    "menu_desc": {"fix": "{{menu_desc}}"},
                    "smenu_desc": {"fix": "{{smenu_desc}}"},
                    "video_desc": {"fix": "{{video_desc}}"},
                    "video_img": {"fix": "{{video_img}}"},
                    "st_cde": {"fix": "{{st_cde}}"},
                    "st_desc": {"fix": "{{st_desc}}"},
                    "ep_cde": {"_attr": "href", "_act": [{"split": {"-": 3}}, {"re": ".html$"}, {"check": {"type": "int"}}]},
                    "ep_url": {"_attr": "href", "_act": [{"pfx": "{{root}}"}]},
                    "ep_desc": {"get": "_text"}
                    }}Executionimport html2obj
ext = html2obj.extract()
obj = ext.extract(conf=ep_conf)
Package: html2pdf
html2pdfA simple python wrapper for wkhtmltopdf forked from python-wkhtmltopdfRequirementsSystem:Linux 32/64 or OSX only (Windows is not supported at this stage)Xvfdwkhtmltopdfpython 2.5+Installationwkhtmltopdf (Linux)Install Xvfd:$ sudo apt-get install xvfbInstall Fonts:$ sudo apt-get install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillicInstall wkhtmltopdf:$ sudo apt-get install wkhtmltopdfwkhtmltopdf (OSX)Install wkhtmltopdf:$ brew install wkhtmltopdfpython-wkhtmltopdf (Any Platform)Development:$ git clone https://bitbucket.org/luisfernando/html2pdf.git
$ cd html2pdf
$ virtualenv .
$ pip install -r requirements.pipPIP:$ pip install git+https://bitbucket.org/luisfernando/html2pdf.git

or from pypi

$ pip install html2pdfUsageSimple Usage::Render a URL:from wkhtmltopdf import HTMLURLToPDF

make_pdf = HTMLURLToPDF(
    url='http://www.example.com',
    output_file='~/example.pdf',
)
make_pdf.render()Render a HTML string:from html2pdf import HTMLToPDF

HTML = """
    <!DOCTYPE html>
    <html>
        <body>
        <h1>Hello World</h1>
        </body>
    </html>
"""

h = HTMLToPDF(HTML, self.output_file)Required Arguments:url- the url to convert to pdfoutput_file- the pdf file that you want to createOptional Arguments:enable-plugins(default: True)disable-javascript(default: False)no-background(default: False)grayscale(default: False)orientation(default: Portrait)dpi(default: 100)username(default: None)password(default: None)margin-bottom(default: 10)margin-top(default: 10)margin-left(default: 10)margin-right(default: 10)disable-smart-shrinking(default: False)Authors:Luis Fernando Barrera (luisfernando@informind.com) @joyinskyForked from wkhtmltopdf
- Jonathan Bydendyk (jpbydendyk@gmail.com)
Package: html2pdf-bookdown
html2pdf_bookdownFetch and convert HTML to PDF for eBooks published withBookdownUsagehtml2pdf_bookdown [-h] [-u URL] [-n BOOK_NAME]E.g.html2pdf_bookdown -u https://christophm.github.io/interpretable-ml-book -n Interpretable-Machine-Learning-by-Christoph-Molnarwill generate a combined PDF namedInterpretable-Machine-Learning-by-Christoph-Molnar.pdfand a directory containing
several PDFs, one for each chapter.InstallationMake sureGoogle Chromehas been installed and the correspondingChromeDriver(needed bySelenium, can be downloaded
fromthis website) is in yourPATH.Then usingpippip install html2pdf_bookdown
Package: html2pdf-server
The name says it all.  You request aPOSTwith an HTML, and then you
will get the response with the rendered PDF.HTTP APISendPOST /request withContent-Type:text/htmle.g.:POST/HTTP/1.1Content-Type:text/html; charset=utf-8Accept:application/pdf<!DOCTYPE><html><body><h1>HTML to be rendered to PDF</h1><p>This document will be rendered to PDF.</p></body></html>(Note that you have to setAccept: application/pdfheader.)And then you will get a PDF document through its response e.g.:HTTP/1.1200OKContent-Type:application/pdfServer:html2pdf-server(...omitted...)Available mime typesYou can setAcceptheader to various mime types.application/pdfrespond a PDF document.  this type is the default type.image/pngrespond a PNG image.image/jpegrespond a JPEG image.Session incurl$catinput.html<!DOCTYPE>
<html>
<body>
  <h1>HTML to be rendered to PDF</h1>
  <p>This document will be rendered to PDF.</p>
</body>
</html>$curl--header'Content-Type: text/html'\--data"`cat input.html`"\--outputoutput.pdf\http://localhost:8080/$openoutput.pdf# Use xdg-open on LinuxResult screenshot:Getting started using DockerDue to its non-Python dependencies the easist way to use this is using Docker.
The official Docker image exposes 8080 port for HTTP server.$dockerrun-p8080:8080spoqa/html2pdf-serverIf you need a pong endpoint for health check specifyPONG_PATHenvironment
variable:$dockerrun-ePONG_PATH=/ping/-p8080:8080spoqa/html2pdf-serverServing on http://0.0.0.0:8080Getting started without DockerInstallationYou can install it usingpip:$pipinstall--usergit+git://github.com/spoqa/html2pdf-server.gitNote thatWeasyPrinthas several dependencies that need to be installed
using system package managers e.g. APT, Homebrew.Read the docs.Running serverUsehtml2pdfdcommand:$html2pdfd--port8080Serving on http://0.0.0.0:8080Or you can use your preferred WSGI server as well (WSGI endpoint ishtml2pdfd:app):$aiohttp-wsgi-servehtml2pdfd:appServing on http://:::8080 http://0.0.0.0:8080LicenseDistributed underAGPLv3or later.ChangelogVersion 1.2.2Released on January 31, 2017.Fixed a crash during the server prints the first log.Version 1.2.1Released on January 31, 2017.Docker image now includes built-in fonts for Chinese/Japanese/Korean.Version 1.2.0Released on January 27, 2017.The prerequisite Python version became 3.5 or higher.
Python 3.4 or lower are no more supported.Replacedwaitresswithaiohttp-wsgi.The Docker image now uses Python 3.5 instead of 3.4.Version 1.1.0Released on January 26, 2017.Added an option to enable pong endpoint for health check.PONG_PATHenvironment variable for Docker.--pong-pathoption for CLI.Fixed a bug that--helpoption crashed while it’s trying to render
default values.Version 1.0.0Initial release.  Released on January 25, 2017.
Package: html2phpbbcode
HTML2PHPBBCodeHTML2PHPBBCode is a Python 3 package that can be used to parse HTML code and convert it to phpBB-compatible BBCode.Usage>>>fromhtml2phpbbcode.parserimportHTML2PHPBBCode>>>parser=HTML2PHPBBCode()>>>parser.feed('<ul><li>Hello</li><li>World</li></ul>')'[list][*]Hello[*]World[/list]'>>>parser.feed('<ol><li>one<li>two</ol>')'[list=1][*]one[*]two[/list]'>>>parser.feed('<a href="https://water.org">Water.org</a>')'[url=https://water.org]Water.org[/url]'>>>parser.feed('<a href="mailto:info@water.org">Mail Water.org</a>')'[email=info@water.org]Mail Water.org[/email]'>>>parser.feed('<strong>Hello <i>World</i>. It&#39;s a wonderful world</strong>')"[b]Hello [i]World[/i]. It's a wonderful world[/b]"AcknowledgementsHTML2PHPBBCode is based on thehtml2bbcodepackage ofVladimir Korsunwhich is available under the BSD License.Theregexpackage byMatthew Barnettis also used, available under the Python Software Foundation License.The code includes some regular expressions from thephpBBbulletin board software as well. Minor changes have been made for Python compatibility. phpBB code is available underGNU GPL v2.0.Differences from html2bbcodeThis package differs from html2bbcode in the following:The generated BBCode follows the syntax described in phpBB'sBBCode guide.<b>,<i>,<u>,
,<ol>HTML tags are also supported.<font>'ssizeattribute handling has been changed so that it maps to reasonable BBCode size values.If thehrefattribute of an<a>link uses themailto:protocol, then the[email]BBCode tag is used.If thehrefattribute of an<a>link is neither an email nor a valid http/https URL, the link is converted to plain-text in BBCode.The parser removes excessive whitespace such as newlines between tags:<p>Hello</p>\n<p>World</p>(TODO: Use theW3C specrules)InstallingThe package is available atPyPIand can be installed with the following command:pipinstallhtml2phpbbcodeInstalling from source is also an option:python3setup.pyinstallTestingpytestis used for testing. Just runpytestin the project directory to execute the tests.
Package: html2png
ImportantThis package is still in the planning/pre-alpha phase.OverviewA Python library and command-line utility to rasterize an
HTML page into a PNG file.TL;DRInstallation:pip install html2pngCommand-line usage:html2png {URL} > output.pngPython usage:import html2png

png = html2png.render('<html><body><p>Hello, world!</p></body></html>')
png = html2png.render_url('http://example.com/')
Package: html2py
[*view Italian version*](README_it.md)# *html*2*py*html2py is a tool for converting an html file in python language and viceversa.## Features- create a pythonic html page.- wrap python code in a function and add imports.- A command line interface for generating script.- Also an API for extend functionalities, see module documenation for more details.## Dependencies- lxml- yattag (for running generated scripts)#### For testing:- hypothesis- pytest (or something that fetch test cases in modules)- xmldiff## Usage#### Command line tool```usage: html2py.py [-h] -o OUTPUT [-e | -f | -c] [-s] fileConvert html file to yattag based python script.parameters:file                  Html file to convert (required).-h, --help            show this help message and exit-o OUTPUT, --output OUTPUTOutput file. By default in output there is pythonheader with imports and a function with code (required).-e, --no-head         Do not insert header and imports.-f, --no-function     Do not insert code into function-c, --only-code       Write only code into output. Do not insert header orfunctions.```#### APIs(see module documentation for more informations)Html2py backend lib is composed with 4 module:- parserParse an input file and transform it into something pythonic.Currently it supported html and xml.- outputIt provides 2 feature:- some extensible objects to represent python instructions- An extensible interface to write your code- yattagUsing parsed data and output module for writing your code.- converterEssentially a connector between cli tool and the other 3 modules.## TODO#### Proposing for future:Now this tool works enough, but it not working in all cases; we need lots of document for testing purposes and for finding unhandled errors.Html2py can potentially pythonize also xml documents and xml based documents, but also other types of file, such as json or yaml.In addition add supports to other xml tree library and not just lxml (currently supported).#### Improve test suite:At the moment there is a very poor test suite (only a case) and this tool, though there is very small in lines of code,  need lots of cases, samples and, why not, a random html generator.#### Add wiki or website for documentationDescribe APIs and tools with a structured doc page instead of this readme.
Package: html2rest
Convert HTML to restructuredText. Very limited, but intended as a “50%” tool, to be
followed by manual editing.Installeasy_install html2restOr:pip install html2restUsageFrom the command line:html2rest http://sphinx.pocoo.org/templating.html > templating.rstOr programmatically:from html2rest import html2rest

stream = StringIO()

html2rest('<ul><li>one</li><li>two</li></ul>', writer=stream)Specify input encoding (default is ‘utf8’) and a preprocessor:def strip_chars(html):
    return html.replace('¶', '')

html2rest(html, writer=stream, encoding='latin1', preprocess=strip_chars)
Package: html2rml
Simple HTML to RML converter. It may be used to take output of TinyMCE
or any other WYSIWYG html editor and use it in your RML template.Installation with pippipinstallhtml2rmlUsageThis HTML code …fromhtml2rmlimporthtml2rmlhtml="""<p>This is text of simple paragraph.<br/> <b>This is bold.</b></p>"""print(html2rml(html))… will be converted to the following RML code.<parastyle="p">Thisistextofsimpleparagraph.<br/><b>Thisisbold.</b></para>