C# 访问 iPhone 构建的网页

发布于 2024-11-08 19:36:53 字数 491 浏览 0 评论 0原文

我正在尝试访问专为 iPhone 构建的 C# 网页。我发现您可以将用户代理欺骗为“Mozilla/5.0(iPhone;U;CPU,如 Mac OS X;en)AppleWebKit/420+(KHTML,如 Gecko)版本/3.0 Mobile/1A543a Safari/ 419.3" 让网站认为您是 iPhone。

但是,对于某些网站,我只收到回复,告诉我先将该网站添加到主屏幕。查看响应,他们似乎正在检查一些变量“window.navigator.standalone”以查看网页是如何访问的。谷歌搜索后(参见此处),这似乎是检测是否从主屏幕访问网页的常用方法。

因此,问题是,是否有人知道如何欺骗请求的其余部分,以便加载网页而不是不断要求添加到主屏幕?

I am trying to accessing webpages in C# which are built specifically for iPhones. I have discovered that you can spoof the user agent to be "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3" to get the website to think you are an iPhone.

However, for some websites, I only get a response telling me to add the website to the home screen first. Looking at the responses, it would seem they are checking some variable "window.navigator.standalone" to see how the webpage was accessed. After googling (see here) it appears this is a common way to detect whether the webpage was accessed from the home screen or not.

Therefore, the question is, does anyone know how to spoof the rest of a request so the webpage will load instead of continually asking to be added to the home screen?

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

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

发布评论

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

评论(1

情场扛把子 2024-11-15 19:36:53

window.navigator.standalone 是在客户端执行的脚本测试,用于检查站点的启动位置(主屏幕或 safari)。欺骗请求中的用户代理将使站点提供内容,但是当站点询问 window.navigator.standalone 时,这显然是错误返回。

您没有提到您是否正在执行脚本,或者您想要实现什么目标,所以我只能推测您请求的站点旨在首先呈现 safari 启动版本,然后在测试时变量将发出备用请求。

你能提供更多细节吗?也许是您请求的站点 URL?

更新:

好吧,那我是对的。如果该脚本不运行,您将看不到正确的站点。我假设您正在处理自己的请求。您需要做的是将另一个请求作为 POST 发送到 Test.aspx,其中发布数据为 hidHomeScreen=true,从而模拟表单提交。

遗憾的是,这不是通用解决方案,因为检测可能因站点实施而异。

window.navigator.standalone is a script test performed on the client side to check from where the site was launched (home screen or safari). Spoofing the user agent in the request will get the site to serve up the content, however when the site is interrogating window.navigator.standalone, it is obviously a false return.

You haven't mentioned whether you are executing the scripts, or what you are trying to achieve so I can only speculate that the site you are requesting is designed to render the safari launch version first, then on testing the variable will make alternate requests.

Could you provide more detail? Perhaps the site URL you are requesting?

UPDATE:

Ok then I am right. If that script does not run, you will not see the proper site. I assume you are dealing with your own requests. What you need to do is send another request as a POST to Test.aspx with post data of hidHomeScreen=true, thus emulating the form submission.

Sadly this is not a generic solution since detection can vary by site implementation.

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