Package org.htmlparser.tags

Examples of org.htmlparser.tags.LinkTag


        Node node = col.children().nextNode();
        assertType(
            "Node identified should be HTMLLinkTag",
            LinkTag.class,
            node);
        LinkTag linkTag = (LinkTag) node;
        Node nodeInsideLink = linkTag.children().nextNode();
        assertType(
            "Tag within link should be an image tag",
            ImageTag.class,
            nodeInsideLink);
        ImageTag imageTag = (ImageTag) nodeInsideLink;
View Full Code Here


        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        {
            Node node = e.nextNode();
            if (node instanceof LinkTag)
            {
                LinkTag linkTag = (LinkTag) node;
                {
                    if (!linkTag.isMailLink())
                    {
                        if (linkTag.getLink().toUpperCase().indexOf("HTM")
                            != -1
                            || linkTag.getLink().toUpperCase().indexOf("COM")
                                != -1
                            || linkTag.getLink().toUpperCase().indexOf("ORG")
                                != -1)
                        {
                            if (crawlDepth > 0)
                            {
                                Parser newParser =
                                    new Parser(
                                        linkTag.getLink(),
                                        new DefaultParserFeedback());
                                newParser.registerScanners();
                                System.out.print(
                                    "Crawling to " + linkTag.getLink());
                                crawl(newParser, crawlDepth - 1);
                            }
                            else
                                System.out.println(linkTag.getLink());
                        }
                    }
                }
            }
        }
View Full Code Here

        System.out.println("Ripping Site " + resourceLocation);
        try
        {
            for (Enumeration e = ripper.rip(); e.hasMoreElements();)
            {
                LinkTag tag = (LinkTag) e.nextElement();
                System.out.println("Ripped mail address : " + tag.getLink());
            }
        }
        catch (ParserException e)
        {
            e.printStackTrace();
View Full Code Here

        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        {
            node = e.nextNode();
            if (node instanceof LinkTag)
            {
                LinkTag linkTag = (LinkTag) node;
                if (linkTag.isMailLink())
                    mailAddresses.addElement(linkTag);
            }
        }
        return mailAddresses.elements();
    }
View Full Code Here

    {
        System.out.println("Parsing " + location + " for links...");
        Node[] links = parser.extractAllNodesThatAre(LinkTag.class);
        for (int i = 0; i < links.length; i++)
        {
            LinkTag linkTag = (LinkTag) links[i];
            // Print it
            //      System.out.println(linkTag.toString());
            System.out.println(linkTag.getLink());
            // To extract only mail addresses, uncomment the following line
            //      if (linkTag.isMailLink()) System.out.println(linkTag.getLink());
        }
    }
View Full Code Here

            }
            else if (node instanceof LinkTag)
            {
                // Node is a link
                // Cast it to an HTMLLinkTag
                LinkTag linkNode = (LinkTag) node;
                // Retrieve the data from the object and print it
                buffer.append(linkNode.getLinkText());
            }
            else if (node instanceof Tag)
            {
                String contents = ((Tag) node).getText();
                if (contents.equals("BR") || contents.equals("P"))
View Full Code Here

    {
        createParser("<A HREF=\".foo.txt\">Foo</A>", "http://www.oygevalt.com");
        parser.registerScanners();
        parseAndAssertNodeCount(1);
        assertTrue(node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
        assertStringEquals(
            "link",
            "http://www.oygevalt.com/foo.txt",
            linkTag.getLink());
        assertEquals("link", "Foo", linkTag.getLinkText());
    }
View Full Code Here

            "view these documents, you must have ",
            stringNode.getText());
        assertTrue(
            "Second node should be a link node",
            node[1] instanceof LinkTag);
        LinkTag linkNode = (LinkTag) node[1];
        assertEquals("Link is", "http://www.adobe.com", linkNode.getLink());
        assertEquals(
            "Link text is",
            "Adobe \r\nAcrobat Reader",
            linkNode.getLinkText());

        assertTrue(
            "Third node should be a string node",
            node[2] instanceof StringNode);
        StringNode stringNode2 = (StringNode) node[2];
View Full Code Here

        parser.addScanner(new LinkScanner("-l"));
        parseAndAssertNodeCount(1);
        assertTrue(
            "Node identified must be a link tag",
            node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
        assertEquals("[> ASGARD <]", linkTag.getLinkText());
        assertEquals("http://asgard.ch", linkTag.getLink());
    }
View Full Code Here

                + "</FORM>");
        parser.addScanner(new FormScanner("", parser));
        parser.addScanner(new LinkScanner());
        parseAndAssertNodeCount(6);
        assertTrue("Fifth Node is a link", node[4] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[4];
        assertEquals("Link Text", "Yahoo!\r\n", linkTag.getLinkText());
        assertEquals("Link URL", "http://www.yahoo.com", linkTag.getLink());
        assertType("Sixth Node", FormTag.class, node[5]);
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.LinkTag

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.