Kevin Bishop | JavaScript Stream Parser / Grabber

JavaScript Stream Parser / Grabber


  • 02 Dec


  • KevinBish

package org.test.parser.media;

import java.util.regex.Matcher;

import java.util.regex.Pattern;

import org.jsoup.Jsoup;

import org.jsoup.nodes.DataNode;

import org.jsoup.nodes.Document;

import org.jsoup.nodes.Element;

import org.jsoup.select.Elements;

 

 

public class App

{

    public static void main( String[] args ) throws Exception

    {

                String url = "";

               

               

                Document doc = Jsoup.connect("http://www.cbc.bb/cbcvideo.html").get();

                //Document doc = Jsoup.parse(html);

               

                Elements scriptTags = doc.getElementsByTag("script");

               

                Pattern p = Pattern.compile("(http.*?[^&\">]+)");

                Matcher m = p.matcher(scriptTags.html());

 

 

                                for (Element tag : scriptTags){               

            for (DataNode node : tag.dataNodes()) {

                System.out.println(node.getWholeData());

                                          

            }       

      }

                               

                                while( m.find() )

                                {

                                    System.out.println("RAW URL: " + m.group()); //Print out Parse HTTP - M3U8

                                               

                                                url = m.group();

                                }

               

                String result = java.net.URLDecoder.decode(url, "UTF-8");

 

   

        System.out.println("DECODED URL: " + result);

               

               

               

    }

}

 

snowflake snowflake snowflake snowflake snowflake snowflake snowflake snowflake snowflake snowflake