如何在 HTML 文档中找到一个数字然后用作 NSString?
在 UIWebView 中,如何找到一个数字(页面上没有其他数字或文本,只有中间的一个数字),然后将其用作 NSString 来使 UILabel 显示该数字?
编辑:网页代码(数字周围):
<div style="width: auto; padding:0px; height: auto;" class="ajax_qe" id="ajax_qe_200139_1"><iframe id='qe_logFrm_200139'
instance='1' class='frog3_enabled' style='display:none;'></iframe><div id="np_200139-1" class="brick s_php_eval" type="PHP"
dfid=""></div><div id="np_200139-2" class="brick s_addspace" type="Blank Space" dfid=""><div style="overflow: hidden; font-size:
0px; width: 100%; height: 5px; "></div></div><div id="np_200139-3" class="brick s_text" type="Text and Pictures" dfid=""><table
border=0 cellspacing=0 cellpadding=0 width='100%' class='alt_200139'><tr><td><P align=center><STRONG><FONT color=#5dd228
size=4>8</FONT></STRONG></P></td></tr></table></div><div class="page_marker" id="edit_link_200139_1" style="display: block;
width:; height:;"><a class="edit_link rootpage" style="display: block;" href="#" onclick="qe_login(200139, 0); return false;"
title="Edit this Page"><img src="/sysimages/editfullpage.gif" style="border: none;" /></a></div><div style="clear: both"></div>
</div><div id="r3603" style="position: relative;text-align: center;width: 100%;"><div style="z-index: 11;position:
static;display: inline;">Powered by <a class=ROLLOVER href="http://www.frogteacher.com/" target=_blank><B>Frog</B></A></div>
谢谢。
In UIWebView, how can I find a number (there's no other numbers or text on the page, just one number in the centre) and then use that as an NSString to make a UILabel show that number?
EDIT: The code of the webpage (around the number):
<div style="width: auto; padding:0px; height: auto;" class="ajax_qe" id="ajax_qe_200139_1"><iframe id='qe_logFrm_200139'
instance='1' class='frog3_enabled' style='display:none;'></iframe><div id="np_200139-1" class="brick s_php_eval" type="PHP"
dfid=""></div><div id="np_200139-2" class="brick s_addspace" type="Blank Space" dfid=""><div style="overflow: hidden; font-size:
0px; width: 100%; height: 5px; "></div></div><div id="np_200139-3" class="brick s_text" type="Text and Pictures" dfid=""><table
border=0 cellspacing=0 cellpadding=0 width='100%' class='alt_200139'><tr><td><P align=center><STRONG><FONT color=#5dd228
size=4>8</FONT></STRONG></P></td></tr></table></div><div class="page_marker" id="edit_link_200139_1" style="display: block;
width:; height:;"><a class="edit_link rootpage" style="display: block;" href="#" onclick="qe_login(200139, 0); return false;"
title="Edit this Page"><img src="/sysimages/editfullpage.gif" style="border: none;" /></a></div><div style="clear: both"></div>
</div><div id="r3603" style="position: relative;text-align: center;width: 100%;"><div style="z-index: 11;position:
static;display: inline;">Powered by <a class=ROLLOVER href="http://www.frogteacher.com/" target=_blank><B>Frog</B></A></div>
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您正在解析的 HTML 始终保持不变(显然,除了您的号码),您可以使用如下内容:
您可以根据需要解析
yourNumber
。另一方面,如果 HTML 将显着不同,我将使用 MWFeedParser 进行解析,但这是一个相当重量级的解决方案。
If the HTML that you are parsing always stays the same (except your number, obviously) you could use something like this:
You can than parse the
yourNumber
however you like.If, on the other hand, the HTML will differ significantly, I would use the MWFeedParser to parse, but this is a rather heavyweight solution.
这应该有效:
This should work: