Exemple #1
0
from urllib.parse import urlunparse
from searx import settings
from searx.plugins import logger
from flask_babel import gettext

name = gettext('Hostname replace')
description = gettext('Rewrite result hostnames')
default_on = False
preference_section = 'general'

plugin_id = 'hostname_replace'
parsed = 'parsed_url'

replacements = {re.compile(p): r
                for (p, r) in settings[plugin_id].items()
                } if plugin_id in settings else {}

logger = logger.getChild(plugin_id)


def on_result(request, search, result):
    if parsed not in result:
        return True
    for (pattern, replacement) in replacements.items():
        if pattern.search(result[parsed].netloc):
            result[parsed] = result[parsed]._replace(
                netloc=pattern.sub(replacement, result[parsed].netloc))
            result['url'] = urlunparse(result[parsed])

    return True
Exemple #2
0
from os import listdir, environ
from os.path import isfile, isdir, join
from searx.plugins import logger
from flask_babel import gettext
from searx import searx_dir

name = "HTTPS rewrite"
description = gettext('Rewrite HTTP links to HTTPS if possible')
default_on = True

if 'SEARX_HTTPS_REWRITE_PATH' in environ:
    rules_path = environ['SEARX_rules_path']
else:
    rules_path = join(searx_dir, 'plugins/https_rules')

logger = logger.getChild("https_rewrite")

# https://gitweb.torproject.org/\
# pde/https-everywhere.git/tree/4.0:/src/chrome/content/rules

# HTTPS rewrite rules
https_rules = []


# load single ruleset from a xml file
def load_single_https_ruleset(rules_path):
    ruleset = ()

    # init parser
    parser = etree.XMLParser()
Exemple #3
0
from os.path import isfile, isdir, join
from searx.plugins import logger
from flask_babel import gettext
from searx import searx_dir


name = "HTTPS rewrite"
description = gettext("Rewrite HTTP links to HTTPS if possible")
default_on = True

if "SEARX_HTTPS_REWRITE_PATH" in environ:
    rules_path = environ["SEARX_rules_path"]
else:
    rules_path = join(searx_dir, "plugins/https_rules")

logger = logger.getChild("https_rewrite")

# https://gitweb.torproject.org/\
# pde/https-everywhere.git/tree/4.0:/src/chrome/content/rules

# HTTPS rewrite rules
https_rules = []


# load single ruleset from a xml file
def load_single_https_ruleset(rules_path):
    ruleset = ()

    # init parser
    parser = etree.XMLParser()