UIWebView 追加UA信息
来源:互联网 发布:淘宝买家退货率高 编辑:程序博客网 时间:2024/06/07 22:15
UIWebView 追加UA信息
// UIWebView+processwebViewUserAgent.m// //// Created by devzkn on 18/09/2017.// Copyright © 2017. All rights reserved.//#import "UIWebView+processwebViewUserAgent.h"@implementation UIWebView (processwebViewUserAgent)/** 先创建一个UIWebView,设置UA,然后删掉它,重新创建你需要的UIWebView */+(void)load{ [self processwebViewUserAgentWithAppendingString:[NSString stringWithFormat:@"gyq_iphone%@",WLAPIVersion1]];}+ (void)processwebViewUserAgentWithAppendingString:(NSString*)appendingString{ //get the original user-agent of webview UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero]; NSString *oldAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; NSLog(@"old agent :%@", oldAgent); //add my info to the new agent NSString *newAgent = [oldAgent stringByAppendingString:appendingString]; NSLog(@"new agent :%@", newAgent); //regist the new agent NSDictionary *dictionnary = [[NSDictionary alloc] initWithObjectsAndKeys:newAgent, @"UserAgent", nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dictionnary];}
获取当前页面的title
self.title= [webView stringByEvaluatingJavaScriptFromString:@"document.title"];//获取当前页面的title
self.currentURL = webView.request.URL.absoluteString; NSLog(@"title-%@--url-%@--",self.title,self.currentURL); NSString *lJs = @"document.documentElement.innerHTML";//获取当前网页的html self.currentHTML = [webView stringByEvaluatingJavaScriptFromString:lJs];
//去除webView底部的黑条
_webView.opaque = NO; _webView.backgroundColor = [UIColor clearColor];
阅读全文
0 0
- UIWebView 追加UA信息
- UA信息
- UA信息
- UA信息
- iOS根据需求修改UIWebView的UA
- UA-tester收集网络服务信息
- crontab追加信息
- 修改UIWebView的ua,加载webOffice的.PDF文件
- UA
- 通过手机型号查找相应UA信息
- js智能获取浏览器版本UA信息
- iOS获取User-Agent(UA)信息的方法
- 手机终端UA信息收集------- X-WAP-PROFILE
- iOS获取User-Agent(UA)信息的方法
- android file 存储 追加信息设置
- java保存控制台信息追加到文件
- linux echo 向文件中追加信息
- 复制文本时追加自定义信息
- 通过BlockingQueue实现生产者和消费者问题
- 一、GIT创建版本库基本命令
- Linux Driver教程PPT
- SAS统计分析学习笔记(八)——T检验和非参数比较
- C++ map基本操作实例
- UIWebView 追加UA信息
- 编译Python源代码
- opencv鼠标经过读取坐标以及划动画框
- #1052最大报销额
- 更轻量的 View Controllers
- Linux之常用基础命令
- hwclock 使用
- LeetCode.92 Reverse Linked List
- 新手微擎(微赞)学习之路二 --- 框架整体认知