Use tor in python or Configure tor in python.

Thinks to do.

1) Download tor from this link and install:- 
https://www.torproject.org/download/ 

2) After installing tor you will get Tor Browser folder 
in Tor Browser folder goto:- Tor folder you have search
as shows in the image below link:
https://ibb.co/hZ0Dx7W 

3) copy the all text from this links:-
https://gitweb.torproject.org/tor.git/tree/src/config/torrc.sample.in  
Past all code to notepad and save as torrc file name
and before saving you search for ControlPort 9051 and HashedControlPassword Uncomment this two lines 
as show'n in image link below and save the file.

https://ibb.co/M5vjsj6

4) Run tor.exe as administrator after running this file Run you need to install this packages.

1) pip install requests -- upgrade
2) pip install requests[socks]
3) pip install stem

5) Run your Python code for example as show'n below.

import requests


def get_tor_session():
    session = requests.session()
    # Tor uses the 9050 port as the default socks port
    session.proxies = {'http': 'socks5://127.0.0.1:9050',
                   'https': 'socks5://127.0.0.1:9050'}
    return session

# # Make a request through the Tor connection
# IP visible through Tor
session = get_tor_session()
print(session.get("http://httpbin.org/ip").text)
# Above should print an IP different than your public IP

# Following prints your normal public IP
print(requests.get("http://httpbin.org/ip").text)
Done.

Reference:-
1) https://www.youtube.com/watch?v=wJfa0qEzpJc
2) https://stackoverflow.com/questions/30286293/make-requests-using-python-over-tor




Comments

Popular posts from this blog

Android Studio 3.5 or above usb device not detected in Android Studio or Unable to detect adb version, exit value: 0xc0000135. ADB depends on the Windows Universal C Runtime, which is usually installed by default via Windows Update. You may need to manually fetch and install the runtime package here: https://support.microsoft.com/en-ca/help/2999226/update-for-universal-c-runtime-in-windows

Lint found fatal errors while assembling a release target.

ViewModelProviders.of(this) is deprecated what to use instead ViewModelProviders.of(this) OR if you don't want to use ViewmodelFactory OR ViewModelProviders error.