Missing script for 854481d
This commit is contained in:
parent
854481dbd3
commit
c58f42476f
1 changed files with 27 additions and 0 deletions
27
profiles/management/commands/import_search_engine.py
Normal file
27
profiles/management/commands/import_search_engine.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
""" 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")
|
Loading…
Reference in a new issue