我想编写获取值流但是失败。 url detect http://m.xemtvhd.com/vtv1.php
如何使用Jsoup获取价值流:http://123.30.215.65/hls/4545780bfa790819/5/3/d836ad614748cdab11c9df291254cf836f21144da20bf08142455a8735b328ca/dnR2MQ==_m.m3u8?
<html>
<head>
<style>html,body{margin:0;padding:0;background:#000;;}</style>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/clappr/latest/clappr.min.js"></script>
<meta name="referrer" content="no-referrer">
</head>
<body>
<div style="width: 100%;">
</div>
<div id="player"></div>
<script>
player = new Clappr.Player({source: "http://123.30.215.65/hls/4545780bfa790819/5/3/d836ad614748cdab11c9df291254cf836f21144da20bf08142455a8735b328ca/dnR2MQ==_m.m3u8",
parentId: '#player',
width: '100%', height: "100%",
hideMediaControl: true,
autoPlay: true
});
</script>
</body>
</html>
&#13;
Code Java me:
Elements script = doc.select("script");
Pattern p = Pattern.compile("player = new Clappr.Player(\\(\"source:{\", \"(.*)\", false\\)");
// ^^ is the capturing group
String url = "";
for (Element element : script) {
Matcher m = p.matcher(element.data());
if (m.find()){
url = m.group(1);
}
}
System.out.println(url);
&#13;
答案 0 :(得分:0)
你的正则表达式中存在一些错误,因为事先将{
置于事后source
之前,你需要双重转义,因为{i,j}
是量词,,
也不是很好,我不知道你为什么这样做,它不是与句子相同的顺序
所以要修复使用:Pattern.compile("player = new Clappr\\.Player\\(\\{source: \"(http:.*)\",.*");
使用正则表达式时,请像regex101一样在线尝试并逐字逐句编写正则表达式,最后您可以尝试用\ d,\ w,...替换word / group以减少< / p>
答案 1 :(得分:0)
@zaro为什么代码正则表达式不支持使用类似格式的代码script.it
<head>
<style>html,body{margin:0;padding:0;background:#000;;}</style>
<meta charset="utf-8">
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/clappr/latest/clappr.min.js"></script>
<meta name="referrer" content="no-referrer">
</head>
<body>
<div style="width: 100%;">
</div>
<div id="player"></div>
<script>
player = new Clappr.Player({source:"http://123.30.215.47/hls/4545780bfa790819/5/3/4b3850f3b3e966aea6ee715c73493ee773f6c45ec2a942b35c941abff6b44e16/dnR2MQ==_m.m3u8",
parentId: '#player',
width: '100%', height: "50%",
hideMediaControl: true,
mediacontrol: {seekbar: "#f00", buttons: "#ff0"},
poster: 'https://lh3.googleusercontent.com/-jHMLMVGcPhI/VqRirYSK0OI/AAAAAAAACEQ/F34hsicLLsU/s600-Ic42/xemtv.png',
position: 'top-right',
autoPlay: true
});
</script>
<iframe scrolling="no" src="vtv1-pc.php" allowfullscreen="true" width="100%" frameborder="0" height="50%"></iframe>
</body>
</html>