使用 Windows 脚本的带有自定义标头字段的 HTTP 请求

发布于 2024-07-14 05:26:00 字数 121 浏览 4 评论 0原文

是否可以使用 Windows Script Host 或任何其他 Windows 脚本技术执行具有特定标头字段(如“referer”、“cookies”或“User-Agent”)的 HTTP 请求?

谢谢。

Is it possible to perform a HTTP Request with specific header fields (like 'referer', 'cookies' or 'User-Agent') using Windows Script Host or any other Windows scripting technology??

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎夕旧梦 2024-07-21 05:26:00

是(VBScript):-

Dim oWinHTTP


Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

oWinHTTP.Open "GET", "http://remoteserver/thing.ext", False
oWinHTTP.SetRequestHeader "User-Agent", "My Agent String"
oWinHTTP.Send

使用 WinHttp 可以为您提供最大程度的控制,如果您想更有效地访问发送的任何 XML DOM,您可以使用 MSXML2.ServerXMLHTTP.3.0。 使用标准的 MSXML2.XMLHTTP.3.0 组件通过 WinINet 为您提供用户代理设置和 cookie 存储等,但会减少您对对话的控制。

Yes (VBScript) :-

Dim oWinHTTP


Set oWinHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")

oWinHTTP.Open "GET", "http://remoteserver/thing.ext", False
oWinHTTP.SetRequestHeader "User-Agent", "My Agent String"
oWinHTTP.Send

Using WinHttp gives you the greatest level of control, you can use MSXML2.ServerXMLHTTP.3.0 if you want more effeciently access any XML DOM sent. Using the standard MSXML2.XMLHTTP.3.0 component goes throught WinINet at gives you the users proxy settings and cookie store etc, but reduces your control over the conversation.

北恋 2024-07-21 05:26:00

我们可以使用 jsp / java 设置像 Cache-control : 'max-age =10000' 这样的请求头吗?
实际上,只有当用户在指定时间(例如 10 分钟)内返回到此页面时,我才想在单击浏览器后退按钮时查看带有旧数据的上一页。

谢谢,
阿努拉格

Can we set the request header like Cache-control : 'max-age =10000' using jsp / java?
Actually I want to see the previous page with old data on click of browser's back button only if user comes back to this page with in a specified time , say 10 minutes.

Thanks,
Anurag

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文