From 3a7b3857008e373bab090595949817e32fe684a0 Mon Sep 17 00:00:00 2001 From: daijro Date: Tue, 20 Dec 2022 08:38:50 -0600 Subject: [PATCH] Escape search query - Escape search query - Repeat last update for startpage - Change default engine back to Bing --- config.json | 2 +- scraper.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 4ce82b3..4139f9f 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "quizlet": true, "quizizz": true, - "search_engine": 1, + "search_engine": 0, "hide_show_key": "Ctrl+D", "ocr_key": "Ctrl+Shift+X", "paste_key": "Ctrl+Shift+V", diff --git a/scraper.py b/scraper.py index c8b7a22..31ee4dc 100644 --- a/scraper.py +++ b/scraper.py @@ -101,7 +101,10 @@ def _init_search(self): def startpage_get_page(self, query, sites): resps = grequests.map([ grequests.post('https://www.startpage.com/sp/search', - data={**self._startpage_data, **{'query': f'{query} site:{site}.com'}}, + data={ + **self._startpage_data, + 'query': f"{query[:self._web_engines[self.engine_name]['limit']-len(site)]} site:{site}.com" + }, session=self.sess ) for site in sites @@ -120,6 +123,8 @@ def get_startpage_items(self, r): def get_page(self, query, sites): self.t.join() + # escape query sequence + query = re.escape(query) if self.engine_name == 'startpage': return self.startpage_get_page(query, sites) elif self.engine_name == 'google':