Skip to content

Commit

Permalink
Escape search query
Browse files Browse the repository at this point in the history
- Escape search query
- Repeat last update for startpage
- Change default engine back to Bing
  • Loading branch information
daijro committed Dec 20, 2022
1 parent aa5f747 commit 3a7b385
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
7 changes: 6 additions & 1 deletion scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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':
Expand Down

0 comments on commit 3a7b385

Please sign in to comment.