#!/usr/local/bin/python3.sh # -*-mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -* # Looks for urls https://dns.google/resolve? # and parses them to extract a magic field. # https://dns.google/resolve?name=domain.name&type=TXT&cd=true&do=true import sys import os from phantompy import Render global LOG import logging import warnings warnings.filterwarnings('ignore') LOG = logging.getLogger() class LookFor(Render): def __init__(self, app, do_print=True, do_save=False): app.lfps = [] self._app = app self.do_print = do_print self.do_save = do_save self.progress = 0 self.we_run_this_tor_relay = None Render.__init__(self, app, do_print, do_save) def _exit(self, val): Render._exit(self, val) self.percent = 100 LOG.debug(f"phantom.py: Exiting with val {val}") i = self.uri.find('name=') fp = self.uri[i+5:] i = fp.find('.') fp = fp[:i] # threadsafe? self._app.lfps.append(fp) def _html_callback(self, *args): """print(self, QPrinter, Callable[[bool], None])""" if type(args[0]) is str: self._save(args[0]) i = self.ilookfor(args[0]) self._onConsoleMessage(i, "__PHANTOM_PY_SAVED__", 0 , '') def ilookfor(self, html): import json marker = '
'
      if marker not in html: return -1
      i = html.find(marker) + len(marker)
      html = html[i:]
      assert html[0] == '{', html
      i = html.find('