Answer the question
In order to leave comments, you need to log in
How to change IP of tor browser in python?
Hello! Faced such a problem that the IP tor browser does not change when parsing. I decided to check what my IP looks like in requests and found such a function.
import requests
from bs4 import BeautifulSoup
import socks
import socket
from time import sleep
def checkIP():
ip = requests.get('http://checkip.dyndns.org').content
soup = BeautifulSoup(ip, 'html.parser')
print(soup.find('body').text)
socks.set_default_proxy(socks.SOCKS5, "localhost", 9150)
socket.socket = socks.socksocket
i = 0
while i <=100:
i += 1
checkIP()
sleep(2)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question