Python 阀杆控制器';的新身份不会更改为IP

Python 阀杆控制器';的新身份不会更改为IP,python,curl,ip-address,tor,stem,Python,Curl,Ip Address,Tor,Stem,下面的问题看起来很像很多相关的问题(我已经通读了它们,但我的问题略有不同,仍然存在) 我使用stem库(在macOS Sierra和Ubuntu上测试)在Python3.6.1中编写了以下代码。它所做的只是创建一个新的tor进程(配置为使用意大利ip),打开一个控制器连接,并在尝试获取新的tor标识并等待30秒后检查ip 我的代码只不过是stem库文档的一个稍加修改的版本,因此,预期可以正常工作 所有的代码似乎都表现良好,我没有收到任何错误/异常,但每次我得到相同的IP(偶尔第二个IP,但在两者

下面的问题看起来很像很多相关的问题(我已经通读了它们,但我的问题略有不同,仍然存在)

我使用stem库(在macOS Sierra和Ubuntu上测试)在Python3.6.1中编写了以下代码。它所做的只是创建一个新的tor进程(配置为使用意大利ip),打开一个控制器连接,并在尝试获取新的tor标识并等待30秒后检查ip

我的代码只不过是stem库文档的一个稍加修改的版本,因此,预期可以正常工作

所有的代码似乎都表现良好,我没有收到任何错误/异常,但每次我得到相同的IP(偶尔第二个IP,但在两者之间切换)

下面是代码(main.py):

下面是程序输出:

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/tommaso/PycharmProjects/test/main.py
May 16 16:33:15.000 [notice] Bootstrapped 0%: Starting
May 16 16:33:16.000 [notice] Bootstrapped 80%: Connecting to the Tor network
May 16 16:33:17.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
May 16 16:33:17.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
May 16 16:33:17.000 [notice] Bootstrapped 100%: Done
IP Address: 162.220.246.230 (162.220.246.230:45631)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:33604)
Locale: 

IP Address: 5.249.145.164 (torexit-readme.balist.es:42397)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:53925)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:42953)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:60250)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:55945)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:44077)
Locale: 

IP Address: 5.249.145.164 (torexit-readme.balist.es:46375)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:33205)
Locale: 

IP Address: 5.249.145.164 (torexit-readme.balist.es:47870)
Locale: 


Process finished with exit code 0
你知道为什么我每次都得到相同的1-2个IP/IP,以及如何修复它吗?我不确定这里出了什么问题。 可能只有两个来自意大利的出口节点(使用意大利IP)


谢谢

您的代码看起来不错,根据您的评论和我看到的输出,它似乎正在工作

在该页面上看到的意大利64-79个节点中,只有少数节点是实际出口(您需要查看图标标志来确定这一点)。根据 你认为意大利的出口要少得多。在撰写本文时,似乎有6个出口在线

至少有一个容量很低(75 KiB/s),可能无法满足您的请求,另外一个我看到的端口80或443不允许退出流量(因此它不适合,也不会被选择供您使用)


总之,事实上你只得到了2个IP,这听起来是对的。这是一个网络容量问题(即在您想要的国家没有理想数量的出口),而不是代码问题。

根据该网站,现在应该有64个意大利人出口节点在线,所以我在询问新身份时应该获得两个以上的IP,对吗?
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/tommaso/PycharmProjects/test/main.py
May 16 16:33:15.000 [notice] Bootstrapped 0%: Starting
May 16 16:33:16.000 [notice] Bootstrapped 80%: Connecting to the Tor network
May 16 16:33:17.000 [notice] Bootstrapped 85%: Finishing handshake with first hop
May 16 16:33:17.000 [notice] Bootstrapped 90%: Establishing a Tor circuit
May 16 16:33:17.000 [notice] Bootstrapped 100%: Done
IP Address: 162.220.246.230 (162.220.246.230:45631)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:33604)
Locale: 

IP Address: 5.249.145.164 (torexit-readme.balist.es:42397)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:53925)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:42953)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:60250)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:55945)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:44077)
Locale: 

IP Address: 5.249.145.164 (torexit-readme.balist.es:46375)
Locale: 

IP Address: 162.220.246.230 (162.220.246.230:33205)
Locale: 

IP Address: 5.249.145.164 (torexit-readme.balist.es:47870)
Locale: 


Process finished with exit code 0