JSoup即使存在元素也不会占用元素

时间:2017-09-18 13:33:59

标签: java android html jsoup

我有一个非常简单的android项目,基本上是一个url的视频播放器,在某个网站上运行完美,jsoup运行html并获取视频的src属性,没有问题,但在另一个它没有拿起因为视频不在标签中,所以我做了以下代码:

I have three fields in my table id,sale_amount,created_at(Sales Date)    

SELECT (SELECT sum(sale_amount) FROM `sales` WHERE created_at = 
CURDATE()) AS todaySale,(SELECT sum(sale_amount) FROM `sales` WHERE 
created_at = CURDATE() -1) AS YesterdaySale,(SELECT sum(sale_amount) 
FROM `sales` WHERE created_at = CURDATE() - 2) AS Last2DaysSale

退出在网站上运行的猫是:

@Override
protected ArrayList<String> doInBackground(String... strings) {

    ArrayList<String> s = new ArrayList<>();

    try {
        Document page = Jsoup.connect(strings[0]).get();

        //Video element
        Element videoPlayer = page.select("video").first();
        Element sourceplayer = page.select("source").first();

        //Page Title
        Element pageTitle = page.select("title").first();

        String src = null;

        if(videoPlayer.attr("src") != null){
            src = videoPlayer.attr("src");
        }else{
            src = sourceplayer.attr("src");
        }

        String title = pageTitle.text();

        s.add(0, title);
        s.add(1, src);

    } catch (IOException e) {
        e.printStackTrace();
    }

    return (s);
}


@Override
protected void onPostExecute(ArrayList<String> s) {
    ti.finishDownloadPage(s);
    Log.i("PageDownloader: ", "Download completo");
    Log.i("Titulo: ", s.get(0));
    Log.i("Src: ", s.get(1));
}

好的,它完美无缺。

从不起作用的网站摘录:

09-18 07:11:24.270 9351-9351/com.samuelives.videoplayer I/PageDownloader:: Download completo
09-18 07:11:24.270 9351-9351/com.samuelives.videoplayer I/Titulo:: Assistir One Punch Man - Episódio 01 - O Homem Mais Poderoso Do Mundo Online
09-18 07:11:24.270 9351-9351/com.samuelives.videoplayer I/Src:: https://www.blogger.com/video-play.mp4?contentId=6bc99b4dd120f980

Logcat只显示:

<video alt="One Piece 805" controls preload="none" width="100%" height="100%" poster="https://www.animakai.info/imagens/848x380/64bb58125874b77c079bf9af2c7ebfc855580f2b.png" data-setup="{}">
                                            <source src="http://www.blogger.com/video-play.mp4?contentId=fb90603b316f558c" type='video/mp4;codecs="avc1.42E01E, mp4a.40.2"'/>
                                            </video>

0 个答案:

没有答案