mpri-webdam/profiles/management/commands/import_keywords.py
2018-02-24 17:21:41 +01:00

20 lines
606 B
Python

""" Small module that import browser fingerprints into the databose,
based on the data listed in https://huit.re/user-agent-json.
"""
import json
from django.core.management.base import BaseCommand
from django.db import models
from profiles.models import Keyword
def import_file(filename):
with open(filename, mode='r') as file:
data = json.load(file)
for _keyword in data["list"]:
keyword = Keyword(text=_keyword.get("keyword", ""))
keyword.save()
class Command(BaseCommand):
def handle(self, *args, **kwargs):
import_file("data/keywords.json")