public class VideoTest {
public static void main(String[] args) throws Exception{
String pic = getElementAttrById("s_sina", "href");
int local = pic.indexOf("pic=");
pic = pic.substring(local+4);
System.out.println("视频缩略图:"+pic);
}
private static String getElementAttrById(String id, String attrName)throws Exception{
Document doc = getURLContent();
Element et = doc.getElementById(id);
String attrValue = et.attr(attrName);
return attrValue;
}
private static Document getURLContent() throws MalformedURLException, IOException, UnsupportedEncodingException {
Document doc = Jsoup.connect("http://v.youku.com/v_show/id_XNTU1MDkyNDYw.html?f=19264429&ev=2")
.data("query", "Java")
.userAgent("Mozilla")
.cookie("auth", "token")
.timeout(3000)
.post();
return doc;
}
}
获取到的是个地址 但我需要的是这张图片 如何获取到图片呢?
求指导!!!!
public static void main(String[] args) throws Exception{
String pic = getElementAttrById("s_sina", "href");
int local = pic.indexOf("pic=");
pic = pic.substring(local+4);
System.out.println("视频缩略图:"+pic);
}
private static String getElementAttrById(String id, String attrName)throws Exception{
Document doc = getURLContent();
Element et = doc.getElementById(id);
String attrValue = et.attr(attrName);
return attrValue;
}
private static Document getURLContent() throws MalformedURLException, IOException, UnsupportedEncodingException {
Document doc = Jsoup.connect("http://v.youku.com/v_show/id_XNTU1MDkyNDYw.html?f=19264429&ev=2")
.data("query", "Java")
.userAgent("Mozilla")
.cookie("auth", "token")
.timeout(3000)
.post();
return doc;
}
}
获取到的是个地址 但我需要的是这张图片 如何获取到图片呢?
求指导!!!!
