Created
November 9, 2021 04:09
-
-
Save Treebug842/2f66384761b2bc438f2b1ea73e5a00b3 to your computer and use it in GitHub Desktop.
Simple code to make a request to .onion sites through tor
This file contains hidden or 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 bs4 import BeautifulSoup | |
url = input("Enter a URL: ") | |
url = "http://darkfailenbsdla5mal2mxn2uz66od5vtzd5qozslagrfzachha3f3id.onion/" if not url else url | |
def get_tor_session(): | |
session = requests.session() | |
session.proxies = {'http': 'socks5h://127.0.0.1:9050', | |
'https': 'socks5h://127.0.0.1:9050'} | |
return session | |
session = get_tor_session() | |
print(f"\nNormal IP Address: {requests.get('http://ifconfig.me').text}") | |
print(f"Tor IP Address: {session.get('http://ifconfig.me').text}\n") | |
request = session.get(url) | |
soup = BeautifulSoup(request.text, "html.parser") | |
print(soup.title.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment