简体   繁体   English

尝试不使用Jsoup解析HTML字符串。 我还有其他选择吗?

[英]Tried to parse HTML String without using Jsoup. Do I have any other options?

Can I put all HTML tags into one array and loop parsing them from my String? 我可以将所有HTML标记放入一个数组中并从String循环解析它们吗? I tried few things around but none are working. 我尝试了一些操作,但没有任何工作。 Help would be appreciated!! 帮助将不胜感激! :) For example: String str = (Head) (title) Hello World (/title) (/head); :)例如:String str =(Head)(title)Hello World(/ title)(/ head);

Can I parse everything between Parentheses. 我可以解析括号之间的所有内容吗? ie (...sometext...) out of my String? 即(... sometext ...)从我的字符串? This is my school project so I'm not allowed to use any other class than basic ones 这是我的学校项目,因此除基础课程外,我不允许使用其他课程

Yes you can as @Jens say in his comment, using regex 是的,您可以使用正则表达式按@Jens在其评论中所述

\((.+?)\)

Capture every character between parentheses. 捕获括号之间的每个字符。

Running example 运行示例

You can use htmlunit 您可以使用htmlunit

HtmlUnit is a "GUI-Less browser for Java programs". HtmlUnit是“用于Java程序的无GUI浏览器”。 It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser. 它为HTML文档建模,并提供一个API,使您可以调用页面,填写表单,单击链接等,就像在“常规”浏览器中一样。

http://htmlunit.sourceforge.net/gettingStarted.html http://htmlunit.sourceforge.net/gettingStarted.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM