使用的IDE:IntellIJ IDEA
Python应用程序的源代码:
from torrequest import TorRequest
with TorRequest() as tr:
response = tr.get('http://ipecho.net/plain')
print(response.text) # not your IP address
tr.reset_identity()
response = tr.get('http://ipecho.net/plain')
print(response.text) # another IP address, not yours
运行 Python 应用程序后出现错误:
C:\Users\Alex\venv\Scripts\python.exe C:/Users/Alex/IdeaProjects/torRequestExperiment/tor.py
Traceback (most recent call last): File "C:/Users/Alex/IdeaProjects/torRequestExperiment/tor.py", line 5, in <module>
with TorRequest() as tr: File "C:\Users\Alex\venv\lib\site-packages\torrequest.py", line 21, in
__init__
self._tor_proc = self._launch_tor() File "C:\Users\Alex\venv\lib\site-packages\torrequest.py", line 41, in
_launch_tor
return launch_tor_with_config( File "C:\Users\Alex\venv\lib\site-packages\stem\process.py", line 296, in launch_tor_with_config
return launch_tor(tor_cmd, args, torrc_path, completion_percent, init_msg_handler, timeout, take_ownership) File "C:\Users\Alex\venv\lib\site-packages\stem\process.py", line 103, in launch_tor
raise OSError("'%s' isn't available on your system. Maybe it's not in your PATH?" % tor_cmd) OSError: 'tor' isn't available on your system. Maybe it's not in your PATH?
Process finished with exit code 1