在JavaScript中为jsoup设置url
我想在JavaScript脚本中设置url以使用jsoup,但我不知道如何设置 以下是我尝试过的:在JavaScript中为jsoup设置url,javascript,html,jsoup,Javascript,Html,Jsoup,我想在JavaScript脚本中设置url以使用jsoup,但我不知道如何设置 以下是我尝试过的: <script language="javascript"> var flObject = swfobject.getFlashPlayerVersion(); var isHtml5 = (location.search.indexOf('isHtml5') != -1) ? true : false; var isDisHtml5 = fal
<script language="javascript">
var flObject = swfobject.getFlashPlayerVersion();
var isHtml5 = (location.search.indexOf('isHtml5') != -1) ? true : false;
var isDisHtml5 = false;
switch (true) {
case navigator.userAgent.indexOf('Firefox') > -1:
isDisHtml5 = true;
break;
case navigator.userAgent.indexOf('MSIE') > -1:
isDisHtml5 = true;
break;
}
if ((!isDisHtml5 && flObject.major == 0) || isHtml5) {
zm('#oplayer').remove();
zm('#_htmlPlayer').removeClass('none');
var HTML5_SKIN = 'skins/jplayer_01';
document.write('<link href="http://static.mp3.zdn.vn/' + HTML5_SKIN + '/css/skin.css" rel="stylesheet" type="text/css" />');
zmCore.addScript('http://static.mp3.zdn.vn/' + HTML5_SKIN + '/js/jquery.min.js', function () {
zmCore.addScript('http://static.mp3.zdn.vn/' + HTML5_SKIN + '/js/jquery.jplayer.min.js', function () {
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "[http://mp3.zing.vn/html5/song/LHcnypFzWANATyDGkH][1]"
});
$(this).jPlayer("play");
},
solution: "html",
supplied: "mp3"
});
});
});
}
</script>
我正在尝试获取mp3:import java.util.ListIterator;
导入java.util.regex.Matcher;
导入java.util.regex.Pattern;
导入javax.swing.text.html.html.Tag;
导入org.jsoup.jsoup;
导入org.jsoup.nodes.Document;
导入org.jsoup.nodes.Element;
导入org.jsoup.select.Elements;
公共班机{
公共静态void main(字符串[]args){
试一试{
Pattern Pattern=Pattern.compile(“.*mp3\\s*:\\s*[\'”]\\[([^\\]]+)\\].*);
String html=“var flObject=swfobject.getFlashPlayerVersion();var isHtml5=(location.search.indexOf('isHtml5')!=-1)?true:false;var isDisHtml5=false;switch(true){case navigator.userAgent.indexOf('Firefox')>-1:isDisHtml5=true;break;case navigator.userAgent.indexOf('MSIE')>-1:isDisHtml5=true;break;}if((!isDisHtml5&&flObject.major==0)| | isHtml5){zm('#oplayer').remove();zm('#htmlPlayer').removeClass('none');var HTML5_SKIN='skins/jplayer_01';document.write('');zmCore.addScript('http://static.mp3.zdn.vn/“+HTML5_SKIN+”/js/jquery.min.js',函数(){zmCore.addScript('http://static.mp3.zdn.vn/“+HTML5\u SKIN+”/js/jquery.jplayer.min.js',function(){$(\“\jquery\u jplayer\u 1\”).jplayer({ready:function(){$(this).jplayer(\“setMedia\”,{mp3:\”[http://mp3.zing.vn/html5/song/LHcnypFzWANATyDGkH][1] \“});$(this.jPlayer(\“play\”);},解决方案:\“html\”,提供:\“mp3\”});});});
Document doc=Jsoup.parse(html);
元素=文件选择(“脚本”);
ListIterator iter=elements.ListIterator();
while(iter.hasNext()){
元素el=iter.next();
if(el.tagName().equalsIgnoreCase(Tag.SCRIPT.toString())){
Matcher Matcher=pattern.Matcher(el.html());
while(matcher.find()){
系统输出println(匹配器组(1));
}
}
}
}捕获(例外e){
e、 printStackTrace();
}
}
}
$(this).jPlayer("setMedia", {
mp3: "[http://mp3.zing.vn/html5/song/LHcnypFzWANATyDGkH][1]"
});
$(this).jPlayer("play");
import java.util.ListIterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.text.html.HTML.Tag;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class Main {
public static void main(String[] args) {
try {
Pattern pattern = Pattern.compile(".*mp3\\s*:\\s*[\"|']\\[([^\\]]+)\\].*");
String html = "<script language=\"javascript\"> var flObject = swfobject.getFlashPlayerVersion(); var isHtml5 = (location.search.indexOf('isHtml5') != -1) ? true : false; var isDisHtml5 = false; switch (true) { case navigator.userAgent.indexOf('Firefox') > -1: isDisHtml5 = true; break; case navigator.userAgent.indexOf('MSIE') > -1: isDisHtml5 = true; break; } if ((!isDisHtml5 && flObject.major == 0) || isHtml5) { zm('#oplayer').remove(); zm('#_htmlPlayer').removeClass('none'); var HTML5_SKIN = 'skins/jplayer_01'; document.write('<link href=\"http://static.mp3.zdn.vn/' + HTML5_SKIN + '/css/skin.css\" rel=\"stylesheet\" type=\"text/css\" />'); zmCore.addScript('http://static.mp3.zdn.vn/' + HTML5_SKIN + '/js/jquery.min.js', function () { zmCore.addScript('http://static.mp3.zdn.vn/' + HTML5_SKIN + '/js/jquery.jplayer.min.js', function () { $(\"#jquery_jplayer_1\").jPlayer({ ready: function () { $(this).jPlayer(\"setMedia\", { mp3: \"[http://mp3.zing.vn/html5/song/LHcnypFzWANATyDGkH][1]\" }); $(this).jPlayer(\"play\"); }, solution: \"html\", supplied: \"mp3\" }); }); }); } </script>";
Document doc = Jsoup.parse(html);
Elements elements = doc.select("script");
ListIterator<Element> iter = elements.listIterator();
while(iter.hasNext()) {
Element el = iter.next();
if(el.tagName().equalsIgnoreCase(Tag.SCRIPT.toString())) {
Matcher matcher = pattern.matcher(el.html());
while (matcher.find()) {
System.out.println(matcher.group(1));
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}