Get Specific elements from HTML in UIWebView

2019-07-20 02:59发布

how can i get specific elements from html page if i have this nsstring with this value

<body style="background-color: 3399CC;font-size: 200.5%;font-family:monospace;font-style:oblique;">


<div id="1" align="center" style="padding-top: 10%;" >
 <h1 style="color: #FFFFFF">fawazapp</h1>
 <p style="color: #C0C0C0;"> bbb</p>
 <p style="color: #FFFFFF;">aaaaaaaaa</p>

 </div>

<div id="2" align="center" style="padding-top: 10%;" >
 <h1 style="color: #FFFFFF">fawazapp</h1>
 <p style="color: #C0C0C0;"> bbb</p>
 <p style="color: #FFFFFF;">aaaaaaaaa</p>

 </div>

I want to clear everything except div with id number 2 to be like this

 </div>

<div id="2" align="center" style="padding-top: 10%;" >
 <h1 style="color: #FFFFFF">fawazapp</h1>
 <p style="color: #C0C0C0;"> bbb</p>
 <p style="color: #FFFFFF;">aaaaaaaaa</p>

 </div>

1条回答
Explosion°爆炸
2楼-- · 2019-07-20 03:38

UIWebView has a method stringByEvaluatingJavaScriptFromString: so if you have (or create) some javascript to navigate / manipulate / interrogate the page contents you can run it to obtain the result.

查看更多
登录 后发表回答