折磨似乎对我有用:
torify wget https://www.some_url.com
这是我的网络服务器上的access.log条目:
207.244.70.35 - - [13/Sep/2018:03:57:25 +0000] "GET / HTTP/1.1" 200 8446 "-" "Wget/1.17.1 (linux-gnu)" "207.244.70.35" response-time=0.02
207.244.70.35不是我的真实IP,因此此命令有效
这是一个Python脚本,它执行与我在这里找到的相同的操作
#! /usr/bin/python3
import subprocess
from subprocess import Popen, PIPE
import sys
import os
# use torify to make a wget
class Wgettor():
def __init__(self, url):
if not self.__is_activated():
print("Ensure Tor service is running")
sys.exit()
else:
self.url = url
self.wget()
# ensure Tor service is running
def __is_activated(self):
service_cmd = "service --status-all | grep tor"
p = subprocess.Popen(service_cmd,
shell=True,
stdout=PIPE).communicate()[0]
return "+" in str(p)
def wget(self):
prox = [
"torify", "wget", self.url
]
os.system(" ".join(prox))
if __name__ == "__main__":
Wgettor("https://www.some_url_here.com")