From 3c84af95ba9307016012a482d67098244a16f7ea Mon Sep 17 00:00:00 2001 From: Brett Kosinski Date: Mon, 31 Oct 2022 15:34:43 -0600 Subject: [PATCH] Fix scraping of 'sc' value from homepage (#3397) 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(