28 lines
837 B
Python
28 lines
837 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 SearchEngine
|
||
|
|
||
|
def import_file(filename):
|
||
|
with open(filename, mode='r') as file:
|
||
|
data = json.load(file)
|
||
|
for search_engine in data:
|
||
|
import_search_engine(search_engine["searchengine"])
|
||
|
|
||
|
def import_search_engine(engine):
|
||
|
search_engine = SearchEngine(
|
||
|
name=engine.get("name", ""),
|
||
|
url=engine.get("url", ""),
|
||
|
query_pattern=engine.get("query_pattern", "")
|
||
|
)
|
||
|
#print(search_engine)
|
||
|
search_engine.save()
|
||
|
|
||
|
class Command(BaseCommand):
|
||
|
def handle(self, *args, **kwargs):
|
||
|
import_file("data/search_engine.json")
|