简体   繁体   English

如何将我的VPN与python请求连接?

[英]How to connect my VPN with the python requests?

My IP is not changing after connecting to the VPN(NordVPN). 连接到VPN(NordVPN)后,我的IP没有更改。 Here's my code: 这是我的代码:

How can I fix this? 我怎样才能解决这个问题? I am noob in python please help by listing the step by step guide. 我是python菜鸟,请列出逐步指南以提供帮助。

import requests
res=requests.get("https://httpbin.org/ip")
print(res.text)

I can't comment on this post so I'll just tell you that you should format code by surrounding it with backticks (this character: ` ). 我不能对这篇文章发表评论,所以我只告诉您,您应该使用反引号(此字符:`)将代码格式化。 Also, please separate each line. 另外,请分开每一行。 Please update your post. 请更新您的帖子。

As for your question, please do understand that Python code is not necessary to check your IP address. 至于您的问题,请务必理解,不需要使用Python代码来检查您的IP地址。 Simply going to that web address in your browser should show you your IP. 只需在浏览器中转到该网址,即可显示您的IP。 Moreover, if your IP address is not changing after enabling a VPN, your VPN is at fault, not Python. 此外,如果启用VPN后您的IP地址没有更改,则说明您的VPN出现了问题,而不是Python。 When I use a VPN and go to that address in the browser, it does work. 当我使用VPN并在浏览器中转到该地址时,它确实起作用。

Finally, I suspect that you are using a NordVPN browser extension, not a system-wide VPN. 最后,我怀疑您使用的是NordVPN浏览器扩展,而不是系统范围的VPN。 In that case, Python is not actually going through your browser to access the web address. 在这种情况下,Python实际上并不会通过浏览器访问网址。 It is directly requesting the information from the webpage. 它直接从网页请求信息。 If you install system-wide, it should work. 如果在系统范围内安装,它应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM