j2me中的html文本提取 [英] html text Extraction in j2me

查看:56
本文介绍了j2me中的html文本提取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从j2me中的网页中提取文本,我使用了String操作,但是我没有得到结果,我的代码正确吗?

I want to extract text from a web page in j2me, I have used String operations,but I am not getting the result, was my code correct?

网页中的字符串:

<td align="left" valign="middle"  class="celebrity-details-description-txt" > 

<p style="text-align: justify;">

 Hero Gopichand's new movie under the direction of Chandrasekhar Yeleti is progressing at brisk pace in Ladakh. Recently, the unit has shot an extensive action scene on Gopichand, Taapsee and others under Buzkashi sport backdrop. alt="Buzkashi sport, gopichand buzkashi, gopichand new movie, buzkashi afghanisthan sport

</p> 

<p style="text-align: justify;">&nbsp;</p> <p style="text-align: justify;">&nbsp;</p>

</td>

这是我的代码:

int tdIndex = readUrl.indexOf("<td align=\"left\" valign=\"middle\" class=\"celebrity-details-description-txt\">");
tdIndex = readUrl.indexOf(">", tdIndex);
int endtdIndex = readUrl.indexOf("</td>", tdIndex);
String content = readUrl.substring(tdIndex + 1, endtdIndex);

推荐答案

readUrl字符串中,在td上的middleclass之间似乎有多余的空格.我的建议是更改

It looks like in readUrl String there is an extra space between middle and class on the td. My suggestion is to change

int tdIndex = readUrl.indexOf("&lt;td align=\"left\" valign=\"middle\" class=\"celebrity-details-description-txt\">");

int tdIndex = readUrl.indexOf("class=\"celebrity-details-description-txt\"");

这篇关于j2me中的html文本提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆