Obfuscates desired content in a Django template in order to be difficult to scrape
The full documentation is at https://django-template-obfuscator.readthedocs.io.
Install django-template-obfuscator:
pip install django-template-obfuscator
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'django_template_obfuscator.apps.DjangoTemplateObfuscatorConfig',
...
)
{% load static %}
{% load obfuscator %}
<!-- Place text to encode in between the {% obfuscate %} and {% endobfuscate %} template
tags, then embed it into an Html element with the "obfuscated" class, that will will be
"deobfuscated" using Javascript -->
<!-- CSS file that will avoid the user to copy the content in obfuscated class -->
<link rel="stylesheet" href="{% static 'css/django_template_obfuscator.css' %}">
<p class="obfuscated">
{% obfuscate %}
Text difficult to scrape.
{% endobfuscate %}
</p>
<p class="obfuscated">
{% obfuscate %}
This text as well.
{% endobfuscate %}
</p>
<!-- JS in charge of deobfuscation, making the content understandable to the web's user -->
<script src="{% static 'js/django_template_obfuscator.js' %}"></script>
- TODO
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install selenium (myenv) $ python django_template_obfuscator/tests.py
Tools used in rendering this package: