html text Extraction in j2me

烈酒焚心 提交于 2020-01-16 00:40:10

问题


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?

The String from a web page:

<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>

Here my CODE:

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);

回答1:


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\">");

to just

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


来源:https://stackoverflow.com/questions/12107974/html-text-extraction-in-j2me

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!