在阻止时,在此Python urllib.request库中通过VPN访问HTTPS /:443

时间:2015-01-03 07:09:41

标签: python github proxy network-programming vpn

我正在使用gh-issues-import在GitHub和GitHub Enterprise服务器之间迁移问题。我遇到的问题是,我们的GHE需要通过VPN代理,而GitHubs API需要HTTPS路由才能访问。我只能得到一个或另一个,但有一段时间找到一种方法来使用urllib.requests通过相同的Python项目访问它们。这是一个按比例缩小的脚本,我用它来使用gh-issues-import ...

中失败的库
import urllib.request

# works through VPN (notice able to use http), requires VPN
GitHubEnterpriseurl = "http://xxxxx/api/v3/"   
req = urllib.request.Request(GitHubEnterpriseurl)
response = urllib.request.urlopen(req)
json_data = response.read()
print(json_data)

# does not work on VPN due to https path, but fine outside of VPN
req = urllib.request.Request("https://api.github.com")
response = urllib.request.urlopen(req)
json_data = response.read()
print(json_data)

我尝试过其他HTTP库,然后归结为对https://api.github.com的VPN阻止访问。有什么解决方案?我可以在另一台服务器上创建脚本,我的VPN可以访问,只需克隆请求并路由数据吗?

*我可以通过浏览器(Chrome / Firefox)使用VPN连接到https://api.github.com,但在运行任何命令行工具或此脚本访问时失败。

0 个答案:

没有答案