How to get value http://api.tivi8k.net/viettel/?cid=154&token=-OWPRmOicPqIKsK97SmOlQ&e=1500542988 using Jsoup?
html:
xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://api.tivi8k.net/viettel/?cid=154&token=-OWPRmOicPqIKsK97SmOlQ&e=1500542988", false); xmlhttp.send(); link = xmlhttp.responseText; player = new Clappr.Player({ source: link, parentId: '#player', width: '100%', height: "100%", hideMediaControl: true, mediacontrol: { seekbar: "#ffaa56", buttons: "#ff7f00" }, autoPlay: true });
html, body { margin: 0; padding: 0; background: #000; ; }
<div style="width: 100%;"> <div id="player"></div> </div> <img src="sv2.png" style="position:absolute;top:5px;right:10px" />
Java code
try {
String userAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36";
Document doc = Jsoup.connect("http://m.xemtvhd.com/vtv1.php").userAgent(userAgent).get();
String url = doc.select("#xmlhttp.open").first().attr("data-source");
System.out.println(url);
} catch (IOException e) {
e.printStackTrace();
}
Please support . Thank for support
This code will take all <script>
elements and iterate over each, then it will check is the one he look is the one with the line you want : the pattern
is here for, if it matches
it will take the group(1)
(represent the capturing group (.*)
, the group(0)
is the whole line) :
Elements script = doc.select("script");
Pattern p = Pattern.compile("xmlhttp.open\\(\"GET\", \"(.*)\", 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); //-> http://...542988
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.