From: Roland Häder Date: Sat, 1 Jul 2023 16:41:06 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=047dbd33a32deed852c050e61f24038a59e9a841;p=fba.git Continued: - if --software parameter is given, no need to fetch whole software list from fediverse.observer --- diff --git a/daemon.py b/daemon.py index acc6cdf..af6cee9 100755 --- a/daemon.py +++ b/daemon.py @@ -341,7 +341,6 @@ def rss(request: Request, domain: str): # Generic instance[key] = domain_data[key] - print(domain_data.keys()) return templates.TemplateResponse("views/infos.html", { "request" : request, "domain" : domain, diff --git a/fba/commands.py b/fba/commands.py index af24675..58fe8a5 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -406,31 +406,34 @@ def fetch_observer(args: argparse.Namespace) -> int: # Acquire lock locking.acquire() - logger.info("Fetching software list ...") - raw = utils.fetch_url( - "https://fediverse.observer", - network.web_headers, - (config.get("connection_timeout"), config.get("read_timeout")) - ).text - logger.debug("raw[%s]()=%d", type(raw), len(raw)) - - doc = bs4.BeautifulSoup(raw, features="html.parser") - logger.debug("doc[]='%s'", type(doc)) + types = list() + if args.software is None: + logger.info("Fetching software list ...") + raw = utils.fetch_url( + "https://fediverse.observer", + network.web_headers, + (config.get("connection_timeout"), config.get("read_timeout")) + ).text + logger.debug("raw[%s]()=%d", type(raw), len(raw)) - items = doc.find("div", {"aria-labelledby": "navbarDropdownMenuSoftwares"}).findAll("a", {"class": "dropdown-item"}) - logger.debug("items[]='%s'", type(items)) + doc = bs4.BeautifulSoup(raw, features="html.parser") + logger.debug("doc[]='%s'", type(doc)) - types = list() + items = doc.find("div", {"aria-labelledby": "navbarDropdownMenuSoftwares"}).findAll("a", {"class": "dropdown-item"}) + logger.debug("items[]='%s'", type(items)) - logger.info("Checking %d menu items ...", len(items)) - for item in items: - logger.debug("item[%s]='%s'", type(item), item) - if item.text.lower() == "all": - logger.debug("Skipping 'All' menu entry ...") - continue + logger.info("Checking %d menu items ...", len(items)) + for item in items: + logger.debug("item[%s]='%s'", type(item), item) + if item.text.lower() == "all": + logger.debug("Skipping 'All' menu entry ...") + continue - logger.debug("Appending item.text='%s' ...", item.text) - types.append(tidyup.domain(item.text)) + logger.debug("Appending item.text='%s' ...", item.text) + types.append(tidyup.domain(item.text)) + else: + logger.info("Adding args.software='%s' as type ...", args.software) + types.append(args.software) logger.info("Fetching %d different table data ...", len(types)) for software in types: diff --git a/fba/http/federation.py b/fba/http/federation.py index b60b051..b053c7c 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -403,7 +403,7 @@ def fetch_generator_from_path(domain: str, path: str = "/") -> str: logger.debug("software[%s]='%s'", type(software), software) if software is not None and software != "": - logger.info("domain='%s' is generated by '%s'", domain, software) + logger.info("domain='%s' is generated by software='%s'", domain, software) instances.set_detection_mode(domain, "GENERATOR") elif isinstance(site_name, bs4.element.Tag) and isinstance(site_name.get("content"), str): logger.debug("Found property=og:site_name, domain='%s'", domain)