如何通过“Clash for Windows”路由互联网流量(来自 Python 代码的 Ping 不起作用)

Adn*_*Ali 5 python windows vpn ping

from os import system
system("ping www.twitter.com")
system("ping www.yahoo.com")
system("ping www.facebook.com")
Run Code Online (Sandbox Code Playgroud)

我在中国,这里禁止推特和脸书。我可以使用Clash for Windows软件在浏览器中打开它们。

我必须从 Twitter 下载推文。所以我需要使用 Python ping 网站来获取推文。虽然我无法ping通网站。

如何让我的 Python 代码使用Clash for Windows.

上面代码的输出:

Pinging www.twitter.com [108.160.169.186] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 108.160.169.186:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

Pinging new-fp-shed.wg1.b.yahoo.com [180.222.102.201] with 32 bytes of data:
Reply from 180.222.102.201: bytes=32 time=258ms TTL=42
Reply from 180.222.102.201: bytes=32 time=229ms TTL=42
Reply from 180.222.102.201: bytes=32 time=230ms TTL=42
Request timed out.

Ping statistics for 180.222.102.201:
    Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
    Minimum = 229ms, Maximum = 258ms, Average = 239ms

Pinging www.facebook.com [69.63.184.14] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 69.63.184.14:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
Run Code Online (Sandbox Code Playgroud)

操作系统:Windows 10(更新到最新版本)。使用 PyCharm 作为我的 IDE。

小智 -1

如果该问题与 Python 或网络相关,让我们尝试隔离该问题。

ping如果直接在shell中运行可以吗?

ping twitter.com
Run Code Online (Sandbox Code Playgroud)

您的 VPN 的设置可能会阻止来自互联网的 Ping。它应该是防火墙中的配置之一。