Skip to content

Instantly share code, notes, and snippets.

@dalf
dalf / debug_engine.py
Created June 10, 2021 11:40
Helper to test engines without UI.
#!/usr/bin/env python
"""
Send one query to to one engine:
* load one engine using the YAML configuration in the ENGINE_SETTINGS_YAML variable.
* get query from the first command line argument.
* get the other parameters from the SEARCH_QUERY variable.
* JSON output.
This script intents to help engine developments and is designed to be hacked in the "Parameters" section.
import os
import io
import re
import csv
import requests
DOCTOLIB_HEADERS = {
'X-Covid-Tracker-Key': os.environ.get('DOCTOLIB_APIKEY', None)
}

To keep searx small, we can extend plugin features.

Directory structure:

__init__.py
static     # directory for the static files
templates  # directory for the jinja2 templates

The template directory allow to add new template results.

@dalf
dalf / dsl.py
Created November 20, 2020 11:09
from abc import abstractmethod
from lxml import html
from searx.utils import extract_text, get_xpath
class XPathDSL:
@abstractmethod
def __rrshift__(self, other):
SELECT ?item ?itemLabel ?itemDescription ?lat ?long ?P571 ?P571timePrecision ?P571timeZone ?P571timeCalendar ?P576 ?P576timePrecision ?P576timeZone ?P576timeCalendar ?P580 ?P580timePrecision ?P580timeZone ?P580timeCalendar ?P582 ?P582timePrecision ?P582timeZone ?P582timeCalendar ?P569 ?P569timePrecision ?P569timeZone ?P569timeCalendar ?P570 ?P570timePrecision ?P570timeZone ?P570timeCalendar ?P619 ?P619timePrecision ?P619timeZone ?P619timeCalendar ?P620 ?P620timePrecision ?P620timeZone ?P620timeCalendar (group_concat(distinct ?P27Label;separator=", ") as ?P27Labels) (group_concat(distinct ?P495Label;separator=", ") as ?P495Labels) (group_concat(distinct ?P17Label;separator=", ") as ?P17Labels) (group_concat(distinct ?Q180Label;separator=", ") as ?Q180Labels) (group_concat(distinct ?P36Label;separator=", ") as ?P36Labels) (group_concat(distinct ?P35Label;separator=", ") as ?P35Labels) (group_concat(distinct ?P6Label;separator=", ") as ?P6Labels) (group_concat(distinct ?P122Label;separator=", ") as ?P122Labels)
import typing
from .. import model
from ..case import async_record_measure
import asyncio
import httpx
"""
httpx HTTP/2
@dalf
dalf / README.md
Last active July 15, 2020 12:48
https everywhere trie
@dalf
dalf / README.md
Last active July 2, 2020 17:32 — forked from florimondmanca/README.md
HTTPX vs aiohttp (over HTTPS)

Usage

  • Generate TLS certificates for localhost:
pip install trustme-cli
trustme-cli
  • Run wrk on each endpoint, eg:
[
{
"name": "searx.space",
"filters": ["Header:X-Forwarded-For=(2001:41d0:8:de3::1|176.31.252.227)"],
"stop": true,
"actions": [{ "name": "log"}]
},
{
"name": "IP limit, all paths",
"interval": 3,
@dalf
dalf / Vagrantfile
Last active April 25, 2020 07:34
PR1803
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at