首页 > 编程知识 正文

python 解析html table,一个完整的java程序示例

时间:2023-05-06 19:11:41 阅读:48431 作者:4193

import org.jsoup.nodes.Element; //部署方法依赖的package软件包/类

publicstaticstringparseforcontent (字符串密钥,元素集嵌入) {

string content=seit embody.outer html (;

//checkifkeyisfoundandremoveeverythinginfront

intkeyoccurrence=content.to lower case ().indexof(key );

if (密钥操作==-1 ) {

返回' ';

} else {

内容=content.substring (keyoccurrencekey.length ();

}

//checkiflinebreakisfoundandremoveeverythinginfront

//assumption : contentisrightafterthekeyandonnewline

intfirstlinebreak=content.index of ('

();

第一行中断(if==-1 ) {

返回' ';

} else {

content=content.substring (第一行中断4;

}

content=content.replaceall('r ','');

content=content.replaceall('n ','');

//onlyreaduntilthenextlinebreak

patternpatternlinebreak=pattern.com pile ('? )

. * ';

matchermatcherlinebreak=pattern line break.matcher (content );

//ifnolinebreaktagisfoundjustreaduntilthenexthtmltagoccurs

patternpatterntag=pattern.com pile ('? () ) );

matchermatchertag=pattern tag.matcher (content );

if(matcherlinebreak.find () ) )

内容=matcher line break.group (1;

}elseif(matchertag.find () ) ) )。

内容=matcher tag.group (1;

} else {

log.debug (noendhtmltagforkey ({} (in ) { } ) parsedfrom )、key、content、seItemBody.outerHtml );

}

content=content.trim (;

返回内容;

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。