Windows中的Javascript文件包含执行PAC文件的功能? [英] Where in Windows is the Javascript file which contains functions for executing PAC files?

查看:109
本文介绍了Windows中的Javascript文件包含执行PAC文件的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代理自动配置(PAC)是一种传统方法,通过该方法,Web浏览器可自动配置为对任何给定站点使用适当的代理。 PAC文件由JavaScript实现的单个函数组成。

Proxy Auto Config (PAC) is the traditional method by which web-browsers are automatically configured to use the appropriate proxy for any given site. PAC files consist of a single function implemented in JavaScript.

我想为另一个puropose执行此函数:我正在尝试创建一个选择代理的应用程序,其使用方式与Microsoft Internet Explorer完全相同可能做。因为我不能简单地询问IE它将用于特定网站的代理,我试图模仿IE在选择用于给定网络资源的代理时会做什么。

I'd like to execute this function for another puropose: I'm trying to make an application which selects a proxy to use in exactly the same way that Microsoft Internet Explorer might do. Since I cannot simply ask IE what proxy it would use for a particular site, I'm trying to emulate what IE would do when it selects which proxy to use for a given web-resource.

使用Windows Scripting主机调用JS函数很容易,但为了执行PAC文件,我需要一些标准函数,例如 shExpMatch isPlainHostName 。这些通常由浏览器提供。 Firefox以易于使用的JS文件提供此文件 - 遗憾的是,FF实现似乎与Microsoft的Javascript实现完全兼容。

It's easy to call a JS function with Windows Scripting host, but in order to execute a PAC file I need a few standard functions such as shExpMatch and isPlainHostName. These are usually provided by the browser. Firefox provides this file in an easy to use JS file - unfortunately the FF implementation does not seem to be perfectly compatible with Microsoft's implementation of Javascript.

我需要找到这些函数的官方微软实现是这样的,我可以在尝试调用函数之前将它们包含在我的脚本环境中。

I need to find where the official microsoft implementations of these functions are so that I can include them in my scripting environment before trying to call the function.

这些可能是哪些想法?

谢谢

更新0:我发现记录的微软功能可能会做我需要的 - 如何在Python 2.4.4中从Win32Com调用这个问题?

Update 0: I found a documented microsoft function which might do what I need - thr question is how can I call this from Win32Com in Python 2.4.4?

推荐答案

我不知道实际的实现在哪里,但是Microsoft已经提供了可以在System.Net命名空间中复制.NET框架中的功能的代码。

I don't know where the actual implementation is, however Microsoft have provided code that you can call that replicates the functionality in the .NET framework, in the System.Net namespace.

该类称为WebProxyScriptHelper,但不幸的是它设置为内部可见性,因此您无法直接调用它(您没有说明您使用的语言,所以这甚至可能不是选项)。幸运的是,微软已经制作了无论如何,源代码可用

The class is called WebProxyScriptHelper, but unfortunately it is set to internal visibility so you can't call it directly (you don't say what language you are using so this may not even be an option). Fortunately, Microsoft have made the source code available anyway.

编辑添加:

还有一个Windows API函数, WinHttpGetProxyForUrl 。也许这就是你应该使用的东西?

There is also a Windows API function, WinHttpGetProxyForUrl. Perhaps this is what you should be using instead?

这篇关于Windows中的Javascript文件包含执行PAC文件的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆