admin管理员组文章数量:1403443
I have an HTML with a javascript as below.
<script type="text/javascript">
if (mnt) {
event.update();
} else {
event.delete();;
}
cf.lmt('45000', '1131452100000', '');</script>
How do I use JSoup to parser this script tag and get the value '1131452100000' which is present in the last line of the script.(which is nothing but an argument). any inputs are appreciated.
I have an HTML with a javascript as below.
<script type="text/javascript">
if (mnt) {
event.update();
} else {
event.delete();;
}
cf.lmt('45000', '1131452100000', '');</script>
How do I use JSoup to parser this script tag and get the value '1131452100000' which is present in the last line of the script.(which is nothing but an argument). any inputs are appreciated.
Share Improve this question asked Jan 24, 2012 at 20:49 GeekGeek 3,32916 gold badges79 silver badges122 bronze badges3 Answers
Reset to default 4I am afraid you can't parse javascript
using Jsoup
to extract your data. Basically Jsoup is an HTML pasrser and HTML and javascript are totally different things.You can see even there are no HTML tags in javascript which jsoup can understand.
You can do one thing load all your content between <script></script>
tags into a string and than use regex
to fetch the required content.
Here is a nice Regex Java Tutorial.
OR You can try using Rhino from Mozilla and using its integration libraries.
You can't use JSoup. It's an HTML parser not a Javascript parser. Try Rhino. You should have javax.script
available.
doc.select("script[type=text/javascript]:not([src~=[a-zA-Z0-9./\s]+)");
本文标签: javaJSoup to parse ltscriptgt tagStack Overflow
版权声明:本文标题:java - JSoup to parse <script> tag - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744333393a2601069.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论