From 371c13cb77a8d4cb8a85b6b1a277ce69ed132aac Mon Sep 17 00:00:00 2001 From: Meinard Francisco <44516102+znarfm@users.noreply.github.com> Date: Thu, 21 Mar 2024 02:58:14 +0800 Subject: [PATCH] Add --bing flag; increase default searches count and search delay (#41) * Add flag if default search engine is Bing * Increase default search count and search delay --- bing_rewards/__init__.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/bing_rewards/__init__.py b/bing_rewards/__init__.py index add795e..09e0528 100644 --- a/bing_rewards/__init__.py +++ b/bing_rewards/__init__.py @@ -53,13 +53,14 @@ # Number of searches to make -DESKTOP_COUNT = 30 -MOBILE_COUNT = 20 +DESKTOP_COUNT = 33 +MOBILE_COUNT = 23 # Time to allow Chrome to load in seconds LOAD_DELAY = 1.5 # Time between searches in seconds -SEARCH_DELAY = 2 +# Searches does not count if they are done earlier than ~6 seconds +SEARCH_DELAY = 6 # Bing Search base url, with new form= parameter (code differs per browser?) URL = "https://www.bing.com/search?form=QBRE&q=" @@ -117,6 +118,12 @@ def parse_args(): help="The full path of the Chrome compatible browser executable", type=check_path, ) + p.add_argument( + "-b", + "--bing", + help="Add this flag if your default search engine is Bing", + action="store_true" + ) # Mutually exclusive options. Only one can be present group = p.add_mutually_exclusive_group() group.add_argument( @@ -303,8 +310,13 @@ def search(count, words_gen: Generator, agent, args, config): # Get a random query from set of words query = next(words_gen) - # Concatenate url with correct url escape characters - search_url = (config.get("search-url") or URL) + quote_plus(query) + # If the --bing flag is set, type the query to the address bar directly + if args.bing: + search_url = query + else: + # Concatenate url with correct url escape characters + search_url = (config.get("search-url") or URL) + quote_plus(query) + # Use pynput to trigger keyboard events and type search querys if not args.dryrun: # Alt + D to focus the address bar in most browsers