From cd2b8672596d4b760c89cebea27cae62ea363aa5 Mon Sep 17 00:00:00 2001 From: Isaac Holt Date: Thu, 3 Feb 2022 16:40:57 -0700 Subject: [PATCH 1/3] Add non-functional code, just in case I want to modify later --- bingbot.py | 36 ++++++++++++++++++++++++++++++++++-- tenlines.txt | 5 ----- testing.txt | 1 - 3 files changed, 34 insertions(+), 8 deletions(-) delete mode 100644 tenlines.txt delete mode 100644 testing.txt diff --git a/bingbot.py b/bingbot.py index d48f332..bf0a26e 100644 --- a/bingbot.py +++ b/bingbot.py @@ -2,7 +2,7 @@ import random searchNum = int(input("Please input the number of tabs you want to open.\nPlease note that the more tabs you open the more ram you will use, and we are not responsible for your computer crashing.\n-->")) - +timesNum = int(input("Please input the number of times you would like to run this.\nie your inputed amount of tabs, times whatever number you input now. The max number of times is 4.\n-->")) num = 0 webLink = [] @@ -10,4 +10,36 @@ webLink.append(f"https://www.bing.com/search?q={(i + 1)}") for i in range(searchNum): webbrowser.open (webLink[i]) -print(webLink) + +if timesNum == 0: + for i in range(searchNum): + webLink.append(f"https://www.bing.com/search?q={(i)}") + for i in range(searchNum): + webbrowser.open (webLink[i]) + +elif timesNum == 1: + for i in range(searchNum + 1): + webLink.append(f"https://www.bing.com/search?q={(i + 2)}") + for i in range(searchNum + 1): + webbrowser.open (webLink[i]) + +elif timesNum == 2: + for i in range(searchNum + 2): + webLink.append(f"https://www.bing.com/search?q={(i + 3)}") + for i in range(searchNum + 2): + webbrowser.open (webLink[i]) + +elif timesNum == 3: + for i in range(searchNum + 3): + webLink.append(f"https://www.bing.com/search?q={(i + 4)}") + for i in range(searchNum + 3): + webbrowser.open (webLink[i]) + +elif timesNum == 4: + for i in range(searchNum + 4): + webLink.append(f"https://www.bing.com/search?q={(i + 5)}") + for i in range(searchNum + 4): + webbrowser.open (webLink[i]) + +else: + print("You either didn't input the correct number, or a number at all.") \ No newline at end of file diff --git a/tenlines.txt b/tenlines.txt deleted file mode 100644 index 86bfc5a..0000000 --- a/tenlines.txt +++ /dev/null @@ -1,5 +0,0 @@ -hello - -Hello this is Isaac and this is a test - -yo yo yo, this is ya boi jSepfh \ No newline at end of file diff --git a/testing.txt b/testing.txt deleted file mode 100644 index 038d718..0000000 --- a/testing.txt +++ /dev/null @@ -1 +0,0 @@ -testing From 686bcc82708de747310c738343786138f8e278b6 Mon Sep 17 00:00:00 2001 From: Isaac Holt Date: Thu, 3 Feb 2022 20:06:36 -0700 Subject: [PATCH 2/3] This is an html file that stays open while the bot runs. You must download to the same directory as the bing bot for it to work. --- Dep1Browser.html | 15 ++++++++++++++ bingbot.py | 54 ++++++++++++------------------------------------ 2 files changed, 28 insertions(+), 41 deletions(-) create mode 100644 Dep1Browser.html diff --git a/Dep1Browser.html b/Dep1Browser.html new file mode 100644 index 0000000..b62c015 --- /dev/null +++ b/Dep1Browser.html @@ -0,0 +1,15 @@ + + + + + Keep your browser open. + + + + + +

This page opened to keep your browser window open while the bing bot completes it's searches.

+ + + + \ No newline at end of file diff --git a/bingbot.py b/bingbot.py index 3ca5370..71ad11d 100644 --- a/bingbot.py +++ b/bingbot.py @@ -1,45 +1,17 @@ import webbrowser -import random +from random import randint +import pyautogui +import time -searchNum = int(input("Please input the number of tabs you want to open.\nPlease note that the more tabs you open the more ram you will use, and we are not responsible for your computer crashing.\n-->")) -timesNum = int(input("Please input the number of times you would like to run this.\nie your inputed amount of tabs, times whatever number you input now. The max number of times is 4.\n-->")) +searchNum = int(input("Please input the number of tabs you want to open.\nEach tab will open once, and then close, so feel free to do as many as you want!\n-->")) +timeNum = int(input("Please input how long you'd like to wait between searches.\nToo short of a time may cause the page to fail to load.\n-->")) -num = 0 -webLink = [] +# We want to have searchNum = the number of tabs open in the browser, and we want to create a random number to update those tabs every 15 seconds, instead of opening a new tab and using too much ram. for i in range(searchNum): - webLink.append(f"https://www.bing.com/search?q={(i + 1)}") -for i in range(searchNum): - webbrowser.open (webLink[i]) - -if timesNum == 0: - for i in range(searchNum): - webLink.append(f"https://www.bing.com/search?q={(i)}") - for i in range(searchNum): - webbrowser.open (webLink[i]) - -elif timesNum == 1: - for i in range(searchNum + 1): - webLink.append(f"https://www.bing.com/search?q={(i + 2)}") - for i in range(searchNum + 1): - webbrowser.open (webLink[i]) - -elif timesNum == 2: - for i in range(searchNum + 2): - webLink.append(f"https://www.bing.com/search?q={(i + 3)}") - for i in range(searchNum + 2): - webbrowser.open (webLink[i]) - -elif timesNum == 3: - for i in range(searchNum + 3): - webLink.append(f"https://www.bing.com/search?q={(i + 4)}") - for i in range(searchNum + 3): - webbrowser.open (webLink[i]) - -elif timesNum == 4: - for i in range(searchNum + 4): - webLink.append(f"https://www.bing.com/search?q={(i + 5)}") - for i in range(searchNum + 4): - webbrowser.open (webLink[i]) - -else: - print("You either didn't input the correct number, or a number at all.") + webbrowser.open(f"https://www.bing.com/search?q={randint(1,200)}") + time.sleep(timeNum) + pyautogui.hotkey('ctrl', 'w') +'''webbrowser.open("google.com") +time.sleep(3) +pyautogui.hotkey('ctrl', 'w') +print("tab closed")''' \ No newline at end of file From d8fcc54cd3b475c0276dfbd4cbd4e972ebd1d0a5 Mon Sep 17 00:00:00 2001 From: Isaac Holt Date: Thu, 3 Feb 2022 20:56:15 -0700 Subject: [PATCH 3/3] Added more functionality, including threading, and a useless way to close browser tabs. --- Dep1Browser.html | 2 +- bingbot.py | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Dep1Browser.html b/Dep1Browser.html index b62c015..a34c8b6 100644 --- a/Dep1Browser.html +++ b/Dep1Browser.html @@ -8,7 +8,7 @@ -

This page opened to keep your browser window open while the bing bot completes it's searches.

+

This page opened to keep your browser window open while the bing bot completes it's searches. It can be safely closed once the searches have completed.

diff --git a/bingbot.py b/bingbot.py index 71ad11d..bf2bafa 100644 --- a/bingbot.py +++ b/bingbot.py @@ -2,16 +2,24 @@ from random import randint import pyautogui import time +import threading +# Define webOpenSearch, which is used for threading so that multiple tabs can be opened at once. +def webOpenSearch(n, n2): + for i in range(n): + webbrowser.open(f"https://www.bing.com/search?q={randint(1,2000)}") + time.sleep(n2) + pyautogui.hotkey('ctrl', 'w') +# Get a variable to tell the system how many tabs to open. searchNum = int(input("Please input the number of tabs you want to open.\nEach tab will open once, and then close, so feel free to do as many as you want!\n-->")) +# Get a variable to tell the system how long to wait before closing a tab. +# Note that I can't get the tabs to close well, with the system usually only closing one or two tabs. timeNum = int(input("Please input how long you'd like to wait between searches.\nToo short of a time may cause the page to fail to load.\n-->")) -# We want to have searchNum = the number of tabs open in the browser, and we want to create a random number to update those tabs every 15 seconds, instead of opening a new tab and using too much ram. -for i in range(searchNum): - webbrowser.open(f"https://www.bing.com/search?q={randint(1,200)}") - time.sleep(timeNum) - pyautogui.hotkey('ctrl', 'w') -'''webbrowser.open("google.com") +# Opens a web page to keep the browser window open, for lighter resource usage, and faster operation. +webbrowser.open("Dep1Browser.html") time.sleep(3) -pyautogui.hotkey('ctrl', 'w') -print("tab closed")''' \ No newline at end of file +# Create a for loop that makes the threads needed to have multiple tabs open, using searchNum to detirmine how many there are. +for i in range(searchNum): + i = threading.Thread(target=webOpenSearch, args=(searchNum,timeNum)) + i.start()