Saravanan666/pypi-org huggingface dataset:
Package: htmlclasses
htmlclassesPython in, HTML out.There are templating engines making it possible to write code
in HTML template files. However, I would very much prefer
to be able to write Python that gets converted to HTML
rather than write Python-like mini language engulfed in HTML.Version0.3.2GoalsGenerating valid HTML from pure Python code.Non-goalsFeatures geared toward JavaScript.I find using 2 intertwined languages too cumbersome.JavaScript is heavily overused and misused.
I don't want to add to the problem.Installationpip install htmlclassesDevelopingThis project is managed with poetry:https://github.com/python-poetry/poetrygit clone git@github.com:uigctaw/htmlclasses.gitpoetry installRunning tests./check_all.shExamplesTo convert Python to HTML run:fromhtmlclassesimportto_stringto_string(html,indent='    ')Hello WorldfromhtmlclassesimportEclasshtml(E):classhead:passclassbody:classp:TEXT='Hello, world!'<!DOCTYPE html><html><head/><body><p>Hello, world!</p></body></html>Repeated ElementsfromhtmlclassesimportEclasshtml(E):classhead(E):# Must sublcass if repeating tagsclassmeta:name='description'content='Framework usage examples'classmeta:# type: ignore[no-redef]  # noqa: F811name='keywords'content='Python, HTML'classbody:classp:TEXT='Hello, world!'<!DOCTYPE html><html><head><metaname="description"content="Framework usage examples"/><metaname="keywords"content="Python, HTML"/></head><body><p>Hello, world!</p></body></html>Work in progressSVG utilities for creating plots.Alternativeshttps://pypi.org/project/html
Package: html-classes-obfuscator
👋 HTML-Classes-Obfuscator 🔒CLI tool that obfuscates HTML classes:Normal HTML file:<divclass="card w-50"><divclass="card-body">Hello World</div></div>Obfuscated HTML file:<divclass="oywdon tgmvkg"><divclass=emnpzm>Hello World</div></div>🚀 UsageVia command line...gitclonegit@github.com:xandermann/html-classes-obfuscator.git

cphtml-classes-obfuscator/html_classes_obfuscator/html_classes_obfuscator.py./YOUR_PROJECT

python3html_classes_obfuscator.py--htmlpath="**/*.html"--csspath="**/*.css"--jspath="**/*.js"...Or via a python script# https://pypi.org/project/html-classes-obfuscator/pipinstallhtml-classes-obfuscatorimportglobimportrandomimportstringfromhtml_classes_obfuscatorimporthtml_classes_obfuscator# [...]htmlfiles=glob.glob("./**/*.html",recursive=True)cssfiles=glob.glob("./**/*.css",recursive=True)jsfiles=glob.glob("./**/*.js",recursive=True)print(htmlfiles)print(cssfiles)print(jsfiles)# Generate random stringdefgenerate_class(current_classes_list):defrandom_class():# Offers (26*2)^6 random class name possibilitiesreturn''.join(random.choice(string.ascii_letters)foriinrange(6))res=random_class()whileresincurrent_classes_list.values():res=random_class()returnreshtml_classes_obfuscator.html_classes_obfuscator(htmlfiles,cssfiles,jsfiles,generate_class)⚠️️ Important notesMake a backup before use.DON'T use if you have duplicate class names in your css files.If you modify the class generator, be sure that the generated name doesn’t begin with a number:In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier “B&W?” may be written as “B&W?” or “B\26 W\3F”.https://www.w3.org/TR/CSS21/syndata.html#characters✅ Run testspython3-munittesttests/*.py🤝 ContributingContributions, issues and feature requests are welcome.Feel free to check issues page if you want to contribute.Check the contributing guide.
Package: html-cleaner
usage: clean up html filespositional arguments:files                 files or directoriesoptional arguments:-h,--helpshow this help message and exit--processorPROCESSORnumber of process--encodingENCODINGfallback to this encoding--no-scriptremove js--cssCSS_FILEinject the content of CSS_FILE to html-r,--recursiverecursive into directory-pPATTERN,--patternPATTERNglob pattern
Package: html-cleaver
HTML Cleaver 🍀🦫Tool for parsing HTML into a chain of chunks with relevant headers.The API entry-point is insrc/html_cleaver/cleaver.The logical algorithm and data-structures are insrc/html_cleaver/handler.This is a "tree-capitator" if you will,cleaving headers together while cleaving text apart.Quickstart:pip install html-cleaverOptionally, if you're working with HTML that requires javascript rendering:pip install seleniumTesting an example on the command-line:python -m html_cleaver.cleaver https://plato.stanford.edu/entries/goedel/Example usage:Cleaving pages of varying difficulties:fromhtml_cleaver.cleaverimportget_cleaver# default parser is "lxml" for loose htmlwithget_cleaver()ascleaver:# handle chunk-events directly# (example of favorable structure yielding high-quality chunks)cleaver.parse_events(["https://plato.stanford.edu/entries/goedel/"],print)# get collection of chunks# (example of moderate structure yielding medium-quality chunks)forcincleaver.parse_chunk_sequence(["https://en.wikipedia.org/wiki/Kurt_G%C3%B6del"]):print(c)# sequence of chunks from sequence of pages# (examples of challenging structure yielding poor-quality chunks)l=["https://www.gutenberg.org/cache/epub/56852/pg56852-images.html","https://www.cnn.com/2023/09/25/opinions/opinion-vincent-doumeizel-seaweed-scn-climate-c2e-spc-intl"]forcincleaver.parse_chunk_sequence(l):print(c)# example of mitigating/improving challenging structure by focusing on certain headerswithget_cleaver("lxml",["h4","h5"])ascleaver:cleaver.parse_events(["https://www.gutenberg.org/cache/epub/56852/pg56852-images.html"],print)Example usage with Selenium:Using selenium on a page that requires javascript to load contents:fromhtml_cleaver.cleaverimportget_cleaverprint("using default lxml produces very few chunks:")withget_cleaver()ascleaver:cleaver.parse_events(["https://www.youtube.com/watch?v=rfscVS0vtbw"],print)print("using selenium produces many more chunks:")withget_cleaver("selenium")ascleaver:cleaver.parse_events(["https://www.youtube.com/watch?v=rfscVS0vtbw"],print)Development:Testing:Testing without Poetry:pip install lxmlpip install seleniumpython -m unittest discover -s srcTesting with Poetry:poetry installpoetry run pytestBuild:Building from source:rm dist/*python -m buildInstalling from the build:pip install dist/*.whlPublishing from the build:python -m twine upload --skip-existing -u __token__ -p $TESTPYPI_TOKEN --repository testpypi dist/*python -m twine upload --skip-existing -u __token__ -p $PYPI_TOKEN dist/*
Package: htmlcomparator
htmlcomparatorThis is a light-weight python package used to compare two html files and return the differences.The users can choose whether they want a boolean result or string result that specify the difference. They can also choose the types of differences they want to receive.UsageTo start using the comparator, first import the package, and make an object.fromhtmlcomparatorimportHTMLComparatorcomparator=HTMLComparator()The method that is used to compare html code iscomparator.compare(html1,html2,quick_compare=True,compare_type="all")html1, html2are the two html to be compared. If they are both strings, it will treat them as two html strings. If they are bothio.IOBaseobjects, then the program will treat them as two opened files. Otherwise the program will raise aTypeError.quick_compareargument is used to specify whether the user want the method to simply return boolean or to return a detailed information of the differences. If it is set to True, then the method will return False as soon as it encounters the first difference, and return True if there are no difference. If it is set to False, then the two html are compared thoroughly, and the method will return astringto describe the differences. If there are no differences, it will return an empty string.compare_typeargument is used to specify the type of differences to compare. It is ignored ifquick_compareis set toTrue. If it is set totag, then only tag differences will be returned. If it is set todatathen tag and data differences will be returned. If it is set toall, then all differences will be considered, including tags, data, and attributes.For example,s1="<!DOCTYPE xml> <head> <p> test </p> <p> different here </p> </head>"s2="<!DOCTYPE html> <head> <p> this is different </p> </head>"comparator=HTMLComparator()print(comparator.compare(s1,s2,compare_type="all",quick_compare=False))will output:@@ DOCTYPE Difference @@
*DOCTYPE xml
-DOCTYPE html

extra tag <p> in the first html at (1, 36)

@@ (1, 25) , (1, 26) @@
*test
-this is differentThe tuples(1, 36),(1, 25), and(1, 25)give the line number and the offset of the differences.LimitationsCurrently doesn't support CSS.LicenseCopyright Mengjia Zhao 2020.
Distributed under the terms of theApache 2.0 license.
Package: htmlcontact
Quick module to read in HTML and tries to identify contacts from the HTML, whether just email, or first,last based matches etc.Usage=====>>> from html_contact import HtmlContact>>> hc = HtmlContact(raw_html)>>> contacts = hc.search()Result list is a list of contacts>>> for result in result_list:...     print result.url...u'http://www.python.org/psf/...What you get is a list of Contacts() instances, each comes with the following values:```pyself.first_name:         fitst name of the contactself.last_name:            last_name of the contactself.email:          email of the contact```=======# html_contactExtracts contact info from website based first/last
Package: html-content-extractor
HTML Content ExtractorThis Python package provides a function to extract the "main content" from HTML documents.Relevancy is determined by an algorithm that favors the deepest parent with the most h1, h2, h3 and p tags.InstallationYou can install this package via pip:$pipinstallhtml-content-extractorUsagefromhtml_content_extractorimportextract_content>>>html="<div><h1>An HTML Page</h1><p>This is some HTML content.</p></div>">>>content=extract_content(html,format='plaintext')>>>print(content)"An HTML Page\n\nThis is some HTML content.">>>markdown=extract_content(html,format='markdown')>>>print(content)"# An HTML Page\n\nThis is some HTML content."
Package: html-converter
HTML Converter ToolSupport Html to Dict, JSON, StrInstallingInstall and update usingpip3:$ pip3 install html_converterPython 3 and newer.Simple Usageif__name__=='__main__':importpprintfromhtml_converterimportHtmlToDicthtml_data='<html><body>test text</body></html>'converter=HtmlToDict()data=converter.convert(html_data,serialize=False)pp=pprint.PrettyPrinter(indent=1)pp.pprint(converter.convert(html_data,serialize=False).to_dict())[{'attrs':{},'inner':[{'attrs':{},'inner':[],'tag':'body','text':'test text'}],'tag':'html','text':''}]print(converter.convert(html_data,serialize=False).to_json())'[{"tag": "html", "attrs":{}, "text": "", "inner": [{"tag": "body", "attrs":{}, "text": "fd", "inner": []}]}]'print(converter.convert(html_data).to_str())testtextSupportPython 3.xSupports all operating systemsLinksLicense:MIT LicenseCode:https://github.com/dinceraslancom/html_converter
Package: html-creator
html-creatorPython library to dynamically generate html in an etree-like structureDocsDocument(title=''): Your HTML document.Argstitle: The title of your document. This is optional and can be specified laterMethodsUsingstr()on this object will return the formatted html content of the Document.PropertiesDocument.children: The direct children of the documentDocument.head: The head tag of the document (automatically generated)Document.body: The body tag of the document (automatically generated)Element(tag='p',attrs={},content=''): A single HTML element/tagArgstag: The tag name, like div, p, or h1attrs: The attributes of the element, in a dictcontent: Text content of your tagMethodsUsingstr()on this object will return the formatted html tag, including formatted html versions of all child tagsUsinglen(Element object)will return the number of childrenUsingElement[index]will return the element at that indexUsingElement.append(new Element object instance)orElement.add_child(new Element object instance)adds a child Element to the ElementPropertiestag,attrs,content: See Argschildren: The direct children on the ElementCSS(Dict={}): A utility class for generating CSSArgsDict: Specifies a starting dictionary (Must be in form{selector: {property: value,property: value,property: value}, selector2: {property: value,property: value,property: value}})Methodsdel CSS[selector]andCSS[selector], respectively, delete and get the specified selector in the CSS objectadd_sel(selector): Adds a selector to add properties toadd_property(selector, property, value): Adds propertypropertywith valuevalueto selectorselectordel_property(selector, property): Deletes propertypropertyfrom selectorselectorstr(CSS object): Returns a formatted CSS stringPropertiesdict: The dictionary used by the CSS object. Can be edited directly, but could cause issues
Package: htmlcrypt
HTMLCryptInspired/Based onMaxLaumeister/PageCrypt.Usagedecrypt.htmldecryptscontent.html.encryptedfrom same folder. Changeconst encryptedFileName = 'content.html.encrypted';to change to a different filename.Usehtmlcrypt -p $PASS -o content.html.encrypted input_file.htmlto encryptinput_file.htmlwith password from$PASS.usage: htmlcrypt [-h] [-p PASSWORD] [-e ENCRYPTED] [-d DECRYPT] [-f] file

Encrypt HTML file with password

positional arguments:
  file                  File to encrypt

options:
  -h, --help            show this help message and exit
  -p PASSWORD, --password PASSWORD
                        Password for encrypting/decrypting. Will ask for password from stdin if not specified
  -e ENCRYPTED, --encrypted ENCRYPTED
                        Encrypted filename
  -d DECRYPT, --decrypt DECRYPT
                        Location to generate the decryption .html file. Relative path to encrypted file will be injected into file.
  -f, --force           Overwrite existing output file
Package: html-css-gen
This is a simple example package to combine html/css files.Quick startfrom html_css_gen import template
payload = {'1': 'file_A',
           '2': 'file_B',
           '3': 'file_C'
           ...
           ...
           ...
         }
emailobj=template.init_template(**payload)
output=emailobj.combine_element()
print(output)combine_element()DescriptionCombine all the element in the email objectReturnA combined html string outputAttentionThis is compulsory to be called upon init (for now)add_parent_html(change_data,]html_tags)DescriptionAdd a parent tag to the combined html filechange_data - thehtml file variable in strto manipulatehtml_tags - [[start_tag, end_tag]ReturnA combined html file with a new wrapper tagadd_customised_css(change_data, css_input)DescriptionAdd on universal css after the html file is created. Ideal for adding code relating to the combined output. The additional css string will be appended at the bottom of the css outputchange_data- the html file variable in str to manipulatecss_input- the customised css snippet you wish to append to your current cssReturnA combined html string output with the customised csspopulate(change_data, **payload,)DescriptionSubstitute the values you wish to replace in the html filechange_data - the html file variable in str to manipulate**payload - a dictionary with the key being the label in the html file in which you wish the value to be replaced and the value being the data to replace withAdditional InfoInsert {variable name} in the parts of html files which you wishes to have the value replacedCall the method with a dictionary payload that has the variable name inserted in the html as the key and the value as the value you wish to replace withexport(filename, export_data)DescriptionExport the combined file into the desired locationfilename - refers to the path in which the file is to be exportedexport_data - being the html string file you wish to export, output of the method aboveReturnNoneFull working examplefrom html_css_gen import template

payload = {'1': 'fileA',
           '2': 'fileB',
           '3': 'fileC'
           }
emailobj=template.init_template(**payload)
template = email_obj.combine_element()
customised_css = '''@media screen and (min-width: 600px) {
                    body {
                        width: 600px; !important
                        }
                    }'''
template_css = email_obj.add_customised_css(
    change_data=template, css_input=customised_css)
template_html = email_obj.add_parent_html(change_data=template_css,
                                          html_tags=[['<div class="sudo">', '</div>']])
final_data = email_obj.populate(template_html,**{'fieldA': 'valueA', 'fieldB': 'valueB'})
email_obj.export(filename='output/unread_email', export_data=final_data)
Package: htmlcutstr
This is repository is an improved version of htmlcutstring (https://code.google.com/p/cut-html-string/).
I’m not the original author.Differences between originalhtmlcutstr has availability to count words instead of charactersIt works fine on both Python 2.x and 3.xInstallationRun ‘setup.py install’ to install this package.UsagecutHtmlString(string, limit, countType=’c’)string is obviously the string you want to cutlimit maximum number of characters/words (depending on countType value) output string can havecountType can be equal to ‘c’ or ‘w’‘c’ means ‘count by characters’‘w’ means ‘count by words’.Examplesfrom htmlcutstr import cutHtmlString

htmlstring = '<div>insert your <a>text</a> here</div>'

print(cutHtmlString(htmlstring, 10)) # '<div>insert you</div>'
print(cutHtmlString(htmlstring, 3, 'w')) # '<div>insert your <a>text</a></div>'
Package: htmlcutstring
It is easy to extract an excerpt of a text string with a given length limit. But
if you want to extract an excerpt from HTML, the tags that may exist in the text
string make it more complicated.This module provides a solution to extract excerpts from HTML documents with a
given text length limit without counting the length of any HTML tags.This package is used to cut the string which is having html tags.
It does not count the html tags, it just count the string inside tags and keeps
the tags as it is.ex: If the string is “welcome to <b>Python World</b> <br/> Python is bla”. and If
we want to cut the string of 16 charaters then output will be “welcome to
<b>Python</b>”.Here while cutting the string it keeps the tags for the cutting string and skip
the rest and without distorbing the div structure.USAGE1:obj = HtmlCutString(“welcome to <b>Python World</b> <br/> Python is”,16)newCutString = obj.cut()USAGE2:newCutString = cutHtmlString(“welcome to <b>Python World</b> <br/> Python is”,16)
Package: htmldammit
Make every effort to properly decode HTML, because HTML is unicode, dammit!FeaturesVery easy to use with integrations forrequestsandurlopen().Utilizes information from HTTP headers, inline encoding declarations,
and UTF BOM-s (Byte Order Marks), as well as falling back to making a
best guess based on the raw data.Improves upon BeautifulSoup’s greatUnicodeDammitutility.Installationpip install htmldammitAdditionally, it ishighlyrecommended to install thecchardetand/or
thechardetlibraries. This will enable the fallback to guessing the
encoding based on the raw data.pip install cchardet chardetBasic usageTo decode any binary HTML content into unicode (passing HTTP headers is optional):fromhtmldammitimportdecode_htmlhtml=decode_html(raw_html,http_headers)To get unicode HTML from arequestsresponse:fromhtmldammit.integrations.requestsimportget_response_htmlresponse=requests.get('http://www.example.org/')html=get_response_html(response)To get unicode HTML from aurlopen()response:fromhtmldammit.integrations.urllibimportget_response_htmlresponse=urlopen('http://www.example.org/')html=get_response_html(response)
Package: htmldata
The htmldata module allows one to translate HTML
documents back and forth to list data structures.
This allows for programmatic reading and writing
of HTML documents, with much flexibility.Functions are also available for extracting
and/or modifying all URLs present in the HTML
or stylesheets of a document.I have found this library useful for writing
robots, for “wrapping” all of the URLs on
websites inside my own proxy CGI script, for
filtering HTML, and for doing flexible wget-like
mirroring.It keeps things as simple as possible, so it
should be easy to learn.Supports XHTML, too.
Package: htmldeps
Use with Python 3.This module supports clean separation of markup, presentation, and behavior in
HTML. It looks for special dependency comments atop CSS and javascript files
and within<style>or<script>tags of the form:/* :depends module1, module2 */The comma separated list following the:dependsstring indicates CSS or
javascript modules that need to be linked into the markup just before each<style>or<script>tag enclosing a dependency comment.After processing, the HTML will contain all the required links to CSS or
javascript modules listed in the markup, along with any of their dependencies.When a CSS or javascript module file requires other modules to be loaded
first, it should provide a dependency comment toward the beginning the source
code. CSS modules may only depend upon other CSS modules, and javascript
modules may depend only on other javascript modules. There may only be one
dependency comment in any module file, and the comment should be somewhere in
the first five lines of the source code.Module names correspond to filenames without an extension, e.g.<style>/*:dependssite*/</style>depends on a file namedsite.css. Module
names must only consist of the ASCII characters matching the regular
expression[a-zA-Z0-9_-].Moudle files are located by looking in the current working directory and then
via whatever paths have been optionally specified in the$HTMLDEPSenvironment variable (formatted just like the ubiquitous$PATHvariable).
In addition, the list of paths to search may also be adjusted via theconfigobject.Within the original HTML, the:dependsstring must only appear in comments
inside of<script>or<style>tags. When a tag contains a dependency
comment, is must not contain any other CSS or javascript expressions: the
comment and its enclosing tag will be removed from the HTML output and
replaced with links to external files. The same module will not be included
more than once in the HTML output.Attributes in the original<script>or<style>tags will be written into
the transformed HTML. For example:<style media="print">/* :depends print */</style>Might render something like this:<link rel="stylesheet" href="print.css" media="print">(For XHTML,<linkrel="stylesheet"href="print.css"media="print"/>)All HTML, CSS, and javascript files must be encoded in utf-8.This module may also be invoked directly from the command line by passing it to
the python interpreter. Run the script with--helpto see the available
command flags:python htmldeps.py --help
Package: htmldiff2
htmldiff2htmldiff2 is a library that usesdifflib,genshiandhtml5libto diff
arbitrary fragments of HTML inline. htmldiff2 is a friendly fork of Armin
Ronacher'shtmldiffwhich needed to be
upgraded for thediffengineproject. Seethis issuefor context.>>>fromhtmldiff2importrender_html_diff>>>render_html_diff('Foo <b>bar</b> baz','Foo <i>bar</i> baz')u'<div class="diff">Foo <i class="tagdiff_replaced">bar</i> baz</div>'>>>render_html_diff('Foo bar baz','Foo baz')u'<div class="diff">Foo <del>bar</del> baz</div>'>>>render_html_diff('Foo baz','Foo blah baz')u'<div class="diff">Foo <ins>blah</ins> baz</div>'
Package: html-diff-wrapper
html_diff_wrapper is an optimized html diff.InstallationAddhtml_diff_wrapperininstall_requiresin yoursetup.py.
and editproduction.iniin your Pyramid application to add:pyramid.includes =
    ...
    html_diff_wrapperContributeIssue Tracker:https://github.com/ecreall/html_diff_wrapper/issuesSource Code:https://github.com/ecreall/html_diff_wrapperLicenseThe project is licensed under the AGPLv3+.Changelog1.0 (2016-09-15)Initial version