欺骗 iPhone 上嵌入式 Safari 浏览器的用户代理?

发布于 2024-07-26 04:11:51 字数 191 浏览 9 评论 0原文

有什么方法可以欺骗 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 技术交流群。

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

发布评论

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

评论(1

绳情 2024-08-02 04:11:51

是的,我认为你可以改变这一点。 需要做一些工作才能使其正常工作。

  1. 您需要手动管理所有请求。 通过提出您自己的数据请求。
    在此数据请求中,您可以为 User-Agent 添加 HTTP 标头,它将覆盖默认标头。

    NSMutableURLRequest* urlRequest = [[[NSMutableURLRequest alloc] initWithURL:requestURL] autorelease];

    [urlRequest setHTTPMethod: @"POST"]; 
      [urlRequest setHTTPBody: [nvpString dataUsingEncoding:NSUTF8StringEncoding]]; 
      [urlRequest addValue:@"您的+用户+代理+字符串" forHTTPHeaderField:@"用户代理"]; 
      receiveData = [[NSMutableData alloc] 保留]; 
      [收到的数据集长度:0]; 
    
      [NSURLConnection connectionWithRequest: urlRequest delegate: self]; 
      
  2. 如果您在应用程序中嵌入 Safari Web 浏览器,则可以订阅其委托方法。 其中之一会通知您的应用程序 safari 想要加载一个 URL,您可以在此处捕获此负载并自行获取数据。

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)请求 navigationType:(UIWebViewNavigationType)navigationType{ 
      

    现在您将代码放在这里来执行数据加载。

  3. 数据加载后。 将数据字符串返回给 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.

  1. 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];

    [urlRequest setHTTPMethod: @"POST"];
    [urlRequest setHTTPBody: [nvpString  dataUsingEncoding:NSUTF8StringEncoding]];
    [urlRequest addValue:@"Your+User+Agent+String" forHTTPHeaderField:@"User-Agent"];
    receivedData = [[NSMutableData alloc] retain];
    [receivedData setLength:0];
    
    [NSURLConnection connectionWithRequest: urlRequest delegate: self];
    
  2. 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.

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    

    now you put your code in here to do the data load.

  3. 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]

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