Browse Source

[fix] pinterest: engine broken due to API changes (#4816)

- apparently the API now requires a `X-Pinterest-PWS-Handler` in order to
  properly function (extracted from their web UI)

- the other `X-Pinterest` headers here are added in case they become mandatory
  too

Closes: https://github.com/searxng/searxng/issues/4812
Bnyro 2 weeks ago
parent
commit
502017b901
1 changed files with 6 additions and 2 deletions
  1. 6 2
      searx/engines/pinterest.py

+ 6 - 2
searx/engines/pinterest.py

@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: AGPL-3.0-or-later
-"""Pinterest (images)
-"""
+"""Pinterest (images)"""
 
 from json import dumps
 
@@ -28,6 +27,11 @@ def request(query, params):
         'context': {},
     }
     params['url'] = f"{base_url}/resource/BaseSearchResource/get/?data={dumps(args)}"
+    params['headers'] = {
+        'X-Pinterest-AppState': 'active',
+        'X-Pinterest-Source-Url': '/ideas/',
+        'X-Pinterest-PWS-Handler': 'www/ideas.js',
+    }
 
     return params