From 131f54820a6a0bb395e34c8046aa9c1e84caabf0 Mon Sep 17 00:00:00 2001 From: Brett Kosinski Date: Sun, 30 Oct 2022 10:42:49 -0600 Subject: [PATCH] Fix scraping of 'sc' value from homepage Looking at the current HTML for the Startpage front page, the previous footer logo element is no longer present. This change scrapes the "sc" parameter from one of the hidden HTML form elements, which should (hopefully) be a bit more stable long term, since that form is used by Startpage to submit requests to the engine. --- searx/engines/startpage.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index 5690e105..23d3de1e 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -91,8 +91,7 @@ def get_sc_code(headers): dom = html.fromstring(resp.text) try: - # href --> '/?sc=adrKJMgF8xwp20' - href = eval_xpath(dom, '//a[@class="footer-home__logo"]')[0].get('href') + href = eval_xpath(dom, '//input[@name="sc"]')[0].get('value') except IndexError as exc: # suspend startpage API --> https://github.com/searxng/searxng/pull/695 raise SearxEngineResponseException(