Package org.htmlparser.tags

Examples of org.htmlparser.tags.ImageTag


           
            //save off the title and image
            item.setTitle(NodeUtils.getTextData(infoCollector.getNode(i++)));

            //get the icon
            ImageTag icon = (ImageTag)infoCollector.getNode(i++);
            item.setIconUrl(icon.getImageURL().replace("&&", "&"));
           
            //strip off the query params
            int index = item.getIconUrl().indexOf('?');
            if (index != -1) {
                item.setIconUrl(item.getIconUrl().substring(0, index)+ "?wid=130&hei=182&cvt=jpeg");
View Full Code Here


                        throw new HTMLParseException(e1);
                    }
                }
                else if (node instanceof ImageTag)
                {
                    ImageTag image= (ImageTag)node;
                    binUrlStr= image.getImageURL();
                }
                else if (node instanceof AppletTag)
                {
                    AppletTag applet= (AppletTag)node;
                    binUrlStr= applet.getAppletClass();
                }
                else if (node instanceof InputTag)
                {
                    InputTag input= (InputTag)node;
                    // we check the input tag type for image
                    String strType= input.getAttribute("type");
                    if (strType != null && strType.equalsIgnoreCase("image"))
                    {
                        // then we need to download the binary
                        binUrlStr= input.getAttribute("src");
                    }
        } else if (node instanceof LinkTag){
          LinkTag link = (LinkTag)node;
          if (link.getChild(0) instanceof ImageTag){
            ImageTag img = (ImageTag)link.getChild(0);
            binUrlStr = img.getImageURL();
          }
        } else if (node instanceof ScriptTag){
          ScriptTag script = (ScriptTag)node;
          binUrlStr = script.getAttribute("src");
        } else if (node instanceof FrameTag){
View Full Code Here

                    }
                } catch (MalformedURLException e1) {
                    throw new HTMLParseException(e1);
                }
            } else if (tag instanceof ImageTag) {
                ImageTag image = (ImageTag) tag;
                binUrlStr = image.getImageURL();
            } else if (tag instanceof AppletTag) {
                // look for applets

                // This will only work with an Applet .class file.
                // Ideally, this should be upgraded to work with Objects (IE)
                // and archives (.jar and .zip) files as well.
                AppletTag applet = (AppletTag) tag;
                binUrlStr = applet.getAppletClass();
            } else if (tag instanceof InputTag) {
                // we check the input tag type for image
                if (ATT_IS_IMAGE.equalsIgnoreCase(tag.getAttribute(ATT_TYPE))) {
                    // then we need to download the binary
                    binUrlStr = tag.getAttribute(ATT_SRC);
                }
            } else if (tag instanceof LinkTag) {
                LinkTag link = (LinkTag) tag;
                if (link.getChild(0) instanceof ImageTag) {
                    ImageTag img = (ImageTag) link.getChild(0);
                    binUrlStr = img.getImageURL();
                }
            } else if (tag instanceof ScriptTag) {
                binUrlStr = tag.getAttribute(ATT_SRC);
            } else if (tag instanceof FrameTag) {
                binUrlStr = tag.getAttribute(ATT_SRC);
View Full Code Here

                    }
                } catch (MalformedURLException e1) {
                    throw new HTMLParseException(e1);
                }
            } else if (tag instanceof ImageTag) {
                ImageTag image = (ImageTag) tag;
                binUrlStr = image.getImageURL();
            } else if (tag instanceof AppletTag) {
            // look for applets

            // This will only work with an Applet .class file.
            // Ideally, this should be upgraded to work with Objects (IE)
            // and archives (.jar and .zip) files as well.
                AppletTag applet = (AppletTag) tag;
                binUrlStr = applet.getAppletClass();
            } else if (tag instanceof InputTag) {
                // we check the input tag type for image
                if (ATT_IS_IMAGE.equalsIgnoreCase(tag.getAttribute(ATT_TYPE))) {
                    // then we need to download the binary
                    binUrlStr = tag.getAttribute(ATT_SRC);
                }
            } else if (tag instanceof LinkTag) {
                LinkTag link = (LinkTag) tag;
                if (link.getChild(0) instanceof ImageTag) {
                    ImageTag img = (ImageTag) link.getChild(0);
                    binUrlStr = img.getImageURL();
                }
            } else if (tag instanceof ScriptTag) {
                binUrlStr = tag.getAttribute(ATT_SRC);
            } else if (tag instanceof FrameTag) {
                binUrlStr = tag.getAttribute(ATT_SRC);
View Full Code Here

                    }
                } catch (MalformedURLException e1) {
                    throw new HTMLParseException(e1);
                }
            } else if (tag instanceof ImageTag) {
                ImageTag image = (ImageTag) tag;
                binUrlStr = image.getImageURL();
            } else if (tag instanceof AppletTag) {
                // look for applets

                // This will only work with an Applet .class file.
                // Ideally, this should be upgraded to work with Objects (IE)
View Full Code Here

          StyleTag styleTag = (StyleTag) tag;
          if ( styleTag.getChildCount() > 0 ) {
            styleTag.removeChild( 0 );
          }
        } else if ( "img".equalsIgnoreCase( name ) && tag instanceof ImageTag ) {
          ImageTag imageTag = (ImageTag) tag;
          imageTag.setImageURL( "NOIMAGE" );
        }
      }

    };
View Full Code Here

        return imgTagCount;
    }

    public int countImageTagsWithHTMLParser() throws ParserException {
        Parser parser = new Parser("http://education.yahoo.com/",new DefaultParserFeedback());
        parser.setNodeFactory (new PrototypicalNodeFactory (new ImageTag ()));
        setParser (parser);
        int parserImgTagCount = 0;
        Node node;
        for (NodeIterator e= parser.elements();e.hasMoreNodes();) {
            node = e.nextNode();
View Full Code Here

        registerTag (new DoctypeTag ());
        registerTag (new FormTag ());
        registerTag (new FrameSetTag ());
        registerTag (new FrameTag ());
        registerTag (new HeadingTag ());
        registerTag (new ImageTag ());
        registerTag (new InputTag ());
        registerTag (new JspTag ());
        registerTag (new LabelTag ());
        registerTag (new LinkTag ());
        registerTag (new MetaTag ());
View Full Code Here

    {
        createParser("<IMG alt=Google height=115 src=\"goo/title_homepage4.gif\" width=305>","http://www.google.com/test/index.html");
        parseAndAssertNodeCount(1);
        // The node should be an HTMLImageTag
        assertTrue("Node should be a HTMLImageTag",node[0] instanceof ImageTag);
        ImageTag imageTag = (ImageTag)node[0];
        assertEquals("The image locn","http://www.google.com/test/goo/title_homepage4.gif",imageTag.getImageURL());
    }
View Full Code Here

    {
        createParser("<IMG alt=Google height=115 src=\"../goo/title_homepage4.gif\" width=305>","http://www.google.com/test/");
        parseAndAssertNodeCount(1);
        // The node should be an HTMLImageTag
        assertTrue("Node should be a HTMLImageTag",node[0] instanceof ImageTag);
        ImageTag imageTag = (ImageTag)node[0];
        assertEquals("The image locn","http://www.google.com/goo/title_homepage4.gif",imageTag.getImageURL());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.ImageTag

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.