Skip to content

Instantly share code, notes, and snippets.

@mIcHyAmRaNe
Last active September 12, 2017 16:00
Show Gist options
  • Save mIcHyAmRaNe/860ca8ffab58d94dfbbbffff23e5a514 to your computer and use it in GitHub Desktop.
Save mIcHyAmRaNe/860ca8ffab58d94dfbbbffff23e5a514 to your computer and use it in GitHub Desktop.
Python 3: tor usage request
#!/usr/bin/env python3
#simple script showing how to let Python ask you if you want to use or not tor ^^
import requests
from colorama import Fore, Back, Style
#NameError: name 'proxies' & 'tor' is not defined
tor=""
proxies=""
#asking you if you want to use tor or no:
while (tor not in ["y","n"]):
tor = input(Fore.YELLOW + 'Would you like to use tor? [Y][n] $ ')
tor = tor.lower().strip()
if tor == "y": #if yes, it gonna setup the proxy
proxies = {
'http': 'socks5://127.0.0.1:9050', #make sure configuring the right port (9150 if using tor browser)
'https': 'socks5://127.0.0.1:9050'
}
elif tor == "n": #if no it gonna continue without configuring proxies
continue
print(requests.get("http://ip.42.pl/raw", proxies=proxies).text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment