Package org.htmlparser.scanners

Examples of org.htmlparser.scanners.LinkScanner


            linkTag.toHtml());
    }

    public void testEvaluate()
    {
        LinkScanner scanner = new LinkScanner("-l");
        boolean retVal = scanner.evaluate("   a href ", null);
        assertEquals(
            "Evaluation of the Link tag",
            new Boolean(true),
            new Boolean(retVal));
    }
View Full Code Here


    public void testExtractLinkInvertedCommasBug() throws ParserException
    {
        String tagContents = "a href=r/anorth/top.html";
        Tag tag = new Tag(new TagData(0, 0, tagContents, ""));
        String url = "c:\\cvs\\html\\binaries\\yahoo.htm";
        LinkScanner scanner = new LinkScanner("-l");
        assertEquals(
            "Extracted Link",
            "r/anorth/top.html",
            scanner.extractLink(tag, url));
    }
View Full Code Here

     * This is the reproduction of a bug which produces multiple text copies.
     */
    public void testExtractLinkInvertedCommasBug2() throws ParserException
    {
        createParser("<a href=\"http://cbc.ca/artsCanada/stories/greatnorth271202\" class=\"lgblacku\">Vancouver schools plan 'Great Northern Way'</a>");
        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(1);
        assertTrue("The node should be a link tag", node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
        assertStringEquals(
            "Extracted Text",
View Full Code Here

     * Links with spaces in them will get their spaces absorbed
     */
    public void testLinkSpacesBug() throws ParserException
    {
        createParser("<a href=\"http://www.kizna.com/servlets/SomeServlet?name=Sam Joseph\">Click Here</A>");
        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(1);
        assertTrue("The node should be a link tag", node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
        assertEquals(
            "Link URL of link tag",
View Full Code Here

        createParser(
            "<LI><font color=\"FF0000\" size=-1><b>Tech Samachar:</b></font><a \n"
                + "href=\"http://ads.samachar.com/bin/redirect/tech.txt?http://www.samachar.com/tech\n"
                + "nical.html\"> Journalism 3.0</a> by Rajesh Jain");
        Parser.setLineSeparator("\r\n");
        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(8);
        assertTrue(
            "Seventh node should be a link tag",
            node[6] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[6];
View Full Code Here

    {
        createParser(
            "<A HREF=\"mytest.html\"> Hello World</A>",
            "http://www.yahoo.com");
        // Register the image scanner
        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(1);
        assertTrue(
            "Node identified should be HTMLLinkTag",
            node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
View Full Code Here

    {
        createParser(
            "<A HREF=\"abc/def/mytest.html\"> Hello World</A>",
            "http://www.yahoo.com");
        // Register the image scanner
        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(1);
        assertTrue(
            "Node identified should be HTMLLinkTag",
            node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
View Full Code Here

    {
        createParser(
            "<A HREF=\"../abc/def/mytest.html\"> Hello World</A>",
            "http://www.yahoo.com/ghi");
        // Register the image scanner
        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(1);
        assertTrue(
            "Node identified should be HTMLLinkTag",
            node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
View Full Code Here

    {
        createParser(
            "<A HREF=\"mytest.html\"><IMG SRC=\"abcd.jpg\">Hello World</A>",
            "http://www.yahoo.com");
        // Register the image scanner
        LinkScanner linkScanner = new LinkScanner("-l");
        parser.addScanner(linkScanner);
        parser.addScanner(linkScanner.createImageScanner("-i"));

        parseAndAssertNodeCount(1);
        assertTrue("Node should be a link node", node[0] instanceof LinkTag);

        LinkTag linkTag = (LinkTag) node[0];
View Full Code Here

    public void testReplaceFaultyTagWithEndTag() throws ParserException
    {
        String currentLine =
            "<p>Site Comments?<br><a href=\"mailto:sam@neurogrid.com?subject=Site Comments\">Mail Us<a></p>";
        Tag tag = new Tag(new TagData(85, 87, "a", currentLine));
        LinkScanner linkScanner = new LinkScanner();
        String newLine =
            linkScanner.replaceFaultyTagWithEndTag(tag, currentLine);
        assertEquals(
            "Expected replacement",
            "<p>Site Comments?<br><a href=\"mailto:sam@neurogrid.com?subject=Site Comments\">Mail Us</A></p>",
            newLine);
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.scanners.LinkScanner

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.