开发者

C# accessing iPhone built webpages

开发者 https://www.devze.com 2023-03-07 08:59 出处:网络
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/

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.

Ho开发者_如何学Cwever, 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消