Skip to content

Instantly share code, notes, and snippets.

@englehardt
Created May 14, 2019 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save englehardt/6e0d1a96f32b9b58a2f6470b7c5a1b74 to your computer and use it in GitHub Desktop.
Save englehardt/6e0d1a96f32b9b58a2f6470b7c5a1b74 to your computer and use it in GitHub Desktop.
Example of how to use the DisconnectParser included in `trackingprotection_tools` (https://pypi.org/project/trackingprotection-tools/)
from trackingprotection_tools import DisconnectParser
BLOCKLIST_URL = 'https://raw.githubusercontent.com/mozilla-services/shavar-prod-lists/master/disconnect-blacklist.json' # noqa
REMAPPING_URL = 'https://raw.githubusercontent.com/mozilla-services/shavar-list-creation/master/disconnect_mapping.json' # noqa
dc = DisconnectParser(
blocklist_url=BLOCKLIST_URL,
disconnect_mapping_url=REMAPPING_URL,
verbose=True
)
base_list = dc.get_domains_with_category(
['Analytics', 'Advertising', 'Social']
)
print("Total number of rules on base list: %d" % len(base_list))
content_list = dc.get_domains_with_category(['Content'])
print("Total number of rules on the strict list: %d" % len(content_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment