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.
This commit is contained in:
Brett Kosinski 2022-10-31 15:34:43 -06:00 committed by GitHub
parent a9a6c58d26
commit 3c84af95ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -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(