欺骗 iPhone 上嵌入式 Safari 浏览器的用户代理?
有什么方法可以欺骗 iPhone 上 Safari 上的用户代理吗?
例如,您可以在具有嵌入式 Safari 浏览器的 iPhone 上创建一个应用程序,但是用户使用此浏览器访问的任何网站都不会知道您正在使用 iPhone 上的 Safari,它会认为您正在使用类似 Safari 的东西PC,甚至 IE/FireFox。
谢谢
Is there any way to spoof the user agent on Safari on the iPhone?
So for example, you would create an application on the iPhone that has the embedded Safari browser, however any website the user visits with this browser wouldn't know you were on Safari on the iPhone, it would think you are on something like Safari on a PC, or even IE/FireFox.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,我认为你可以改变这一点。 需要做一些工作才能使其正常工作。
您需要手动管理所有请求。 通过提出您自己的数据请求。
在此数据请求中,您可以为 User-Agent 添加 HTTP 标头,它将覆盖默认标头。
NSMutableURLRequest* urlRequest = [[[NSMutableURLRequest alloc] initWithURL:requestURL] autorelease];
如果您在应用程序中嵌入 Safari Web 浏览器,则可以订阅其委托方法。 其中之一会通知您的应用程序 safari 想要加载一个 URL,您可以在此处捕获此负载并自行获取数据。
现在您将代码放在这里来执行数据加载。
数据加载后。 将数据字符串返回给 webView。 我已经设置了“baseURL:nil”,但您可能必须将其正确设置为该应用程序的正确域。
[webView loadHTMLString:newString baseURL:nil]
Yes I think you could change this. It would require a bit of a work around to get it working.
You would need to manually manage all requests. By making your own data requests.
In this data request you can add a HTTPheader for User-Agent which will override the default headers.
NSMutableURLRequest* urlRequest = [[[NSMutableURLRequest alloc] initWithURL:requestURL] autorelease];
If you embed the Safari Web Browser in your app you can subscribe to its delegate methods. One of them will notify your application that safari would like to load a URL, this is where you catch this load and get the data your self.
now you put your code in here to do the data load.
Once the data has loaded. Give it the data string back to the webView. I have set "baseURL:nil" but you might have to correctly set this to maybe the correct domain for this app.
[webView loadHTMLString:newString baseURL:nil]