Javascript 通过代理服务器的GM_xmlhttpRequest
关于这一点,我还没有具体的问题,更重要的是,在我知道这一点之前,我无法开始工作,也无法找到答案,所以我将使用一些随机的片段来演示 假设我有剧本:Javascript 通过代理服务器的GM_xmlhttpRequest,javascript,post,proxy,get,greasemonkey,Javascript,Post,Proxy,Get,Greasemonkey,关于这一点,我还没有具体的问题,更重要的是,在我知道这一点之前,我无法开始工作,也无法找到答案,所以我将使用一些随机的片段来演示 假设我有剧本: GM_xmlhttpRequest({ method: "GET", url: server + "SyncWatcher/get.php?ckey=" + privatekey, onload: function(response) { document.getElementById("cfinder").innerHTML+="<span i
GM_xmlhttpRequest({
method: "GET",
url: server + "SyncWatcher/get.php?ckey=" + privatekey,
onload: function(response) {
document.getElementById("cfinder").innerHTML+="<span id='kswlst' style='display:none;'>" + response.responseText + "</span>";}});
但是,它加载的IP仍然是我自己的地址,因此它没有使用代理。
如何使用提供的代理服务器?。(也没有一个适合我的。)
通常,对于ISP或公司代理,您需要按照提供商的说明进行操作GM_xmlhttpRequest()
将自动使用该代理,只要目标站点不在Firefox的“无代理”列表中
您的代码应该是:
GM_xmlhttpRequest ( {
method: "GET",
url: "AN ORDINARY URL THAT IS *NOT* IN THE 'NO PROXY' LIST",
onload: function (response) {
document.getElementById ("targin").innerHTML=response.responseText;
}
} );
对于一次性或选择性使用代理,它们通常通过URL参数或表单post获取目标URL。您需要确定正在使用的代理的详细信息 在这种情况下,您可以指向代理URL,并提供相应的数据。
例如,假设您的代理接受
GET
请求,并按如下方式配置:
Proxy IP: 188.2.38.197
Port: 8080
Path: GimmeGimme
Parameter: thisUrl
然后,您将按如下方式获取页面:
var targetURL = "http://YOUR_SERVER.COM/YOUR_PATH/";
var ajaxURL = 'http://188.2.38.197:8080/GimmeGimme?thisUrl='
+ encodeURIComponent (targetURL)
;
GM_xmlhttpRequest ( {
method: "GET",
url: ajaxURL,
onload: function (response) {
document.getElementById ("targin").innerHTML=response.responseText;
}
} );
我花了这么长时间才看到这个,这正是我所需要的,谢谢:)
Proxy IP: 188.2.38.197
Port: 8080
Path: GimmeGimme
Parameter: thisUrl
var targetURL = "http://YOUR_SERVER.COM/YOUR_PATH/";
var ajaxURL = 'http://188.2.38.197:8080/GimmeGimme?thisUrl='
+ encodeURIComponent (targetURL)
;
GM_xmlhttpRequest ( {
method: "GET",
url: ajaxURL,
onload: function (response) {
document.getElementById ("targin").innerHTML=response.responseText;
}
} );