【问题标题】:Using opensubtitles api Node.js/Python wrapper behind a proxy在代理后面使用 opensubtitles api Node.js/Python 包装器
【发布时间】:2019-01-10 13:10:18
【问题描述】:
我正在尝试在代理后面使用 opensubtitles api 的 opensubtitles-api node.js 包装器。不幸的是,没有可用的代理选项。该库反过来使用node-xmlrpc 进行RPC 调用。但是底层的node-xmlrpc 库也不支持代理隧道。我的项目还受益于一些python 库和代码。但是python 包装器似乎也不处理代理。我有哪些选择?
【问题讨论】:
标签:
python
node.js
proxy
xml-rpc
subtitle
【解决方案1】:
由于node-xmlrpc 使用的是http/https,因此您可以指定这样的代理。
const xmlrpc = require('xmlrpc');
const options = {
host: "proxy_url",
port: 8080, // proxy port
path: "http://opensubtitles_url",
headers: {
Host: "opensubtitles_domain",
"Proxy-Authorization": "Basic bXl1c2VyOm15cGFzc3dvcmQ=" // if needed
}
};
const client = xmlrpc.createClient(options);