Package org.htmlparser.scanners

Examples of org.htmlparser.scanners.ScriptScanner


        String testHTML1 = new String(sb1.toString());

        createParser(testHTML1, "http://www.google.com/test/index.html");
        Parser.setLineSeparator("\r\n");
        // Register the image scanner
        parser.addScanner(new ScriptScanner("-s"));

        parseAndAssertNodeCount(2);

        StringBuffer sb2 = new StringBuffer();
        sb2.append("if(navigator.appName.indexOf(\"Netscape\") != -1)\r\n");
View Full Code Here


                + "<!--\r\n"
                + "// -->\r\n"
                + "</SCRIPT>";
        createParser(testHtml);

        parser.addScanner(new ScriptScanner("-s"));
        parseAndAssertNodeCount(1);
        ScriptTag scriptTag = (ScriptTag) node[0];
        assertStringEquals("scriptag html", testHtml, scriptTag.toHtml());
    }
View Full Code Here

     * script tag was not closed before the document ended.
     */
    public void testScanNoEndTag() throws ParserException
    {
        createParser("<script>");
        parser.addScanner(new ScriptScanner("-s"));
        parseAndAssertNodeCount(1);
    }
View Full Code Here

     * See bug #741769 ScriptScanner doesn't handle quoted </script> tags
     */
    public void testScanQuotedEndTag() throws ParserException
    {
        createParser("<SCRIPT language=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>");
        parser.addScanner(new ScriptScanner("-s"));
        parseAndAssertNodeCount(1);
        String s = node[0].toHtml();
        assertEquals(
            "Parse error",
            "<SCRIPT LANGUAGE=\"JavaScript\">document.write('</SCRIPT>');</SCRIPT>",
View Full Code Here

        // Note - The BaseHREF and Image scanners share the same
        // link processor - internally linked up with the factory
        // method in the link scanner class
        addScanner(linkScanner);
        addScanner(linkScanner.createImageScanner(ImageTag.IMAGE_TAG_FILTER));
        addScanner(new ScriptScanner("-s"));
        addScanner(new StyleScanner("-t"));
        addScanner(new JspScanner("-j"));
        addScanner(new AppletScanner("-a"));
        addScanner(new MetaTagScanner("-m"));
        addScanner(new TitleScanner("-T"));
View Full Code Here

                            // Taken from org.htmlparser.Parser
        // add input tag scanner
        parser.addScanner(new InputTagScanner());
        // add applet tag scanner
        parser.addScanner(new AppletScanner());
        parser.addScanner(new ScriptScanner());
        parser.addScanner(new LinkTagScanner());
        parser.addScanner(new FrameScanner());
    }
View Full Code Here

    /**
     * Create a new script tag.
     */
    public ScriptTag ()
    {
        setThisScanner (new ScriptScanner ());
    }
View Full Code Here

    /**
     * Create a new script tag.
     */
    public ScriptTag ()
    {
        setThisScanner (new ScriptScanner ());
    }
View Full Code Here

  public void testScan() throws ParserException {
    String testHtml = "<SCRIPT>document.write(d+\".com\")</SCRIPT>";
    createParser(testHtml, "http://www.google.com/test/index.html");
    // Register the script scanner
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    // Check the data in the applet tag
    ScriptTag scriptTag = (ScriptTag) node[0];
    assertStringEquals("Expected Script Code", "document.write(d+\".com\")", scriptTag.getScriptCode());
View Full Code Here

   */
  public void testScanBug() throws ParserException {
    createParser("<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"../js/DetermineBrowser.js\"></SCRIPT>",
        "http://www.google.com/test/index.html");
    // Register the image scanner
    parser.addScanner(new ScriptScanner("-s"));
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a script tag", node[0] instanceof ScriptTag);
    // Check the data in the applet tag
    ScriptTag scriptTag = (ScriptTag) node[0];
    Hashtable table = scriptTag.getAttributes();
View Full Code Here

TOP

Related Classes of org.htmlparser.scanners.ScriptScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.