Created
January 3, 2024 10:50
-
-
Save itsmeadarsh2008/b681e247c7e6bd605d5cc61715cba5b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from colorama import Fore, Style | |
import threading | |
# Function to send a single request to the specified URL | |
def send_request(url): | |
try: | |
response = requests.get(url) | |
if response.status_code == 200: | |
print(f"{Fore.GREEN}[SUCCESS]{Style.RESET_ALL} Request to {url} successful") | |
else: | |
print(f"{Fore.RED}[ERROR]{Style.RESET_ALL} Request to {url} failed with status code {response.status_code}") | |
except Exception as e: | |
print(f"{Fore.RED}[ERROR]{Style.RESET_ALL} Exception while sending request to {url}: {str(e)}") | |
# Function to send bulk requests to the specified URL | |
def send_bulk_requests(url, num_requests): | |
print(f"Sending {num_requests} requests to {url}...\n") | |
# Create a list of threads to send requests concurrently | |
threads = [] | |
for _ in range(num_requests): | |
thread = threading.Thread(target=send_request, args=(url,)) | |
threads.append(thread) | |
thread.start() | |
# Wait for all threads to complete | |
for thread in threads: | |
thread.join() | |
if __name__ == "__main__": | |
from colorama import init | |
init(autoreset=True) # Initialize Colorama | |
# Take input for the number of requests and website URL | |
num_requests = int(input("Enter the number of requests to send: ")) | |
website_url = input("Enter the website URL: ") | |
# Validate URL | |
if not website_url.startswith("http://") and not website_url.startswith("https://"): | |
website_url = "http://" + website_url | |
# Send bulk requests | |
send_bulk_requests(website_url, num_requests) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment