From e51da5b712b167fba8cf46368bf277c3fe2372e1 Mon Sep 17 00:00:00 2001 From: Jonas Tranberg Date: Thu, 3 Jan 2019 18:39:43 +0100 Subject: [PATCH] If only status_code is needed use HEAD instead of GET request to avoid body download --- .gitignore | 6 ++++++ sherlock.py | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1fc7d19..d1db3b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ # Virtual Environment venv/ +# vscode +.vscode/ + +# Python +__pycache__/ + # Jupyter Notebook .ipynb_checkpoints *.ipynb diff --git a/sherlock.py b/sherlock.py index dd38b26..617a2c1 100644 --- a/sherlock.py +++ b/sherlock.py @@ -130,8 +130,14 @@ def sherlock(username, verbose=False, tor=False, unique_tor=False): url = net_info["url"].format(username) results_site["url_user"] = url + # If only the status_code is needed don't download the body + if net_info["errorType"] == 'status_code': + request_method = session.head + else: + request_method = session.get + # This future starts running the request in a new thread, doesn't block the main thread - future = session.get(url=url, headers=headers) + future = request_method(url=url, headers=headers) # Store future in data for access later net_info["request_future"] = future