Instantly share code, notes, and snippets.

Embed
What would you like to do?
# DON'T BE A DICK PUBLIC LICENSE
#
# > Version 1.1, December 2016
# > Copyright (C) [year] [fullname]
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document.
#
# > DON'T BE A DICK PUBLIC LICENSE
# > TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 1. Do whatever you like with the original work, just don't be a dick.
#
# Being a dick includes - but is not limited to - the following instances:
#
# 1a. Outright copyright infringement - Don't just copy this and change the name.
# 1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
# 1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
#
# 2. If you become rich through modifications, related works/services, or supporting the original work,
# share the love. Only a dick would make loads off this work and not buy the original work's
# creator(s) a pint.
#
# 3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
# you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.
# To use:
# - Install the requests module with pip (something like `python -mpip install requests`)
# - Add any filters as strings (comma separated and in quotes) to FILTERS if you want to only block specific reasons.
#
# Works with any blocklist that formats its json akin to dzuk-mutant/blockchain.
# dzuk-mutants is preloaded, you can see the available filters here: https://github.com/dzuk-mutant/blockchain/blob/master/list/json-list.md
# Change BASE_URL to some other blockchain list that formats in the same way if you want to use a different list.
import requests
import csv
BASE_URL = "https://github.com/dzuk-mutant/blockchain/raw/master/list/list.json"
FILTERS = [] # Leave empty to match all reasons
print("Downloading json...")
json_data = requests.get(BASE_URL).json()
print("Making your blockchain...")
with open("blockchain.csv", "w") as blockchain:
writer = csv.writer(blockchain)
for entry in json_data["block"]:
if FILTERS:
if any(reason in entry["reasons"] for reason in FILTERS):
writer.writerow([entry["domain"]])
else:
writer.writerow([entry["domain"]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment