0
안녕하세요. 웹 사이트 스크래핑에 대한 일부 요청 후 내 IP를 변경하려고했지만 일부 코드에서이 코드를 실행하면 아무 일도 일어나지 않습니다. 두 출력에서 동일합니다. 누구든지 내가 뭘 잘못하고 있는지 알 수 있니?왜 내 ip를 바꿀 수 없습니까? Tor & Python
from stem import Signal
from stem.control import Controller
import requests
def set_new_ip():
"""Change IP using TOR"""
with Controller.from_port(port=9051) as controller:
controller.authenticate(password='my_password')
controller.signal(Signal.NEWNYM)
local_proxy = '127.0.0.1:8118'
http_proxy = {'http://': local_proxy,
'https://': local_proxy}
current_ip = requests.get(url='http://icanhazip.com/',
proxies=http_proxy,
verify=False)
print(current_ip.text)
set_new_ip()
current_ip = requests.get(url='http://icanhazip.com/',
proxies=http_proxy,
verify=False)
print(current_ip.text)