zoukankan      html  css  js  c++  java
  • ios webView JS代码加载

     从网页加本体图片-

    NSString *boundle = [[NSBundle mainBundle] resourcePath];
    [web1 loadHTMLString:[NSString stringWithFormat:@"<img src='http://fei263.blog.163.com/blog/0001.png'/>"] baseURL:[NSURL fileURLWithPath:boundle]];

    从网页加载图片并让图片在规定长宽中缩小
    [cell.img loadHTMLString:[NSString stringWithFormat:@"<html><body><img src='http://fei263.blog.163.com/blog/%@' height='90px' width='90px'></body></html>",goodsInfo.GoodsImg] baseURL:nil];
    将网页加载到webview上通过javascript获取里面的数据,如果只是发送了一个连接请求获取到源码以后可以用正则表达式进行获取数据
    NSString *javaScript1 = @"document.getElementsByName('.u').item(0).value";
    NSString *javaScript2 = @"document.getElementsByName('.challenge').item(0).value";
    NSString *strResult1 = [NSString stringWithString:[theWebView stringByEvaluatingJavaScriptFromString:javaScript1]];
    NSString *strResult2 = [NSString stringWithString:[theWebView stringByEvaluatingJavaScriptFromString:javaScript2]];

    做一个顶天立地的男子,并且自信,健康微笑的生活下去!
  • 相关阅读:
    虚拟机vmware的连接方式以及IP端口,协议等概念
    python3爬虫--shell命令的使用和firefox firebug获取目标信息的xpath
    numpy的基本用法
    scrapy模拟请求头
    (1)python Scrapy爬虫框架
    flutter ui
    dart 类
    dart 基础
    黑苹果镜像下载地址
    android9.0请求异常
  • 原文地址:https://www.cnblogs.com/luoxiao1115/p/3041254.html
Copyright © 2011-2022 走看看