zzm*_*zzm 7 proxy node.js electron
我正在用电子在Windows上编写桌面应用程序.现在我需要使用System全局代理设置作为我自己的代理,同时使用request来获取这样的数据
request({
url: "http://ahdas.drnh.gov.tw/index.php",
method: "POST",
proxy: this.proxyRequestUrl,
headers: {
"User-Agent": this.mainWindow.webContents.session.getUserAgent(),
"Accept": "application/json, text/javascript, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Cookie": cookies
},
form: {'act': 'Display/built/' + bookKey + "/" + postPageKey}
}, (err, response, body) => {
});
Run Code Online (Sandbox Code Playgroud)
那么,我如何获得系统全局代理设置并将其分配给this.proxyRequestUrl?
如果您从渲染器进行 http 调用,它将使用系统默认代理设置。
如果您需要从主进程进行http调用,您可以使用电子远程远程ajax模块,它将通过渲染器进程进行调用。
您也可以在主进程中使用electron-fetch,它将使用系统代理设置。
| 归档时间: |
|
| 查看次数: |
1513 次 |
| 最近记录: |