Skip to main content

W3C services for python.

Project description

Installation:
pip install py_w3c

Usage:
1. As library -

# import HTML validator
from py_w3c.validators.html.validator import HTMLValidator

# create validator instance
vld = HTMLValidator()

# validate
vld.validate('http://example.com')

# look for errors
print(vld.errors) # list with dicts

# look for warnings
print(vld.warnings)

There are 3 methods of validating:
1. validate url - HTMLValidator().validate(url)
2. validate file - HTMLValidator().validate_file(filename_or_file) # StringIO aware.
3. validate fragment - HTMLValidator().validate_fragment(fragment_string)

You can pass charset while creating validator instance. This will force validator to use passed charset for validation.
Example (python).
vld = HTMLValidator(charset='utf-8')

# now validator uses utf-8 charset ignoring charset in the document content
vld.validate('http://example.com')

2. As standalone script - (not very usefull right now)
Now only URL validating is allowed for standalone script.
$ w3c_validate http://example.com
Prints warnings and errors to the console.

Running tests.
$ python setup.py test
This command will install tox and run tests for py2.7 and py3.4.

To run test for one python version use (py2.7 for example):
$ python setup.py test -a "-epy27"

Project details


Release history Release notifications

This version
History Node

0.3.1

History Node

0.2.0

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
py_w3c-0.3.1.tar.gz (6.5 kB) Copy SHA256 hash SHA256 Source None Jan 11, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page