e.g. Calendar Search Help
You must enter a value before pressing Search
jmeter

Class: org.htmlparser.tests.BenchmarkP   ©

 OK to copy?
001 // $Header: /home/cvs/jakarta-jmeter/src/htmlparser/org/htmlparser/tests/BenchmarkP.java,v 1.3 2004/02/18 22:49:56 sebb Exp $
002 /*
003  * ====================================================================
004  * Copyright 2002-2004 The Apache Software Foundation.
005  *
006  * Licensed under the Apache License, Version 2.0 (the "License");
007  * you may not use this file except in compliance with the License.
008  * You may obtain a copy of the License at
009  *
010  *   http://www.apache.org/licenses/LICENSE-2.0
011  *
012  * Unless required by applicable law or agreed to in writing, software
013  * distributed under the License is distributed on an "AS IS" BASIS,
014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015  * See the License for the specific language governing permissions and
016  * limitations under the License.
017  * 
018  */
019 
020 package org.htmlparser.tests;
021 
022 import java.io.File;
023 import java.net.MalformedURLException;
024 
025 import org.htmlparser.*;
026 import org.htmlparser.scanners.*;
027 import org.htmlparser.tags.*;
028 import org.htmlparser.util.*;
029 
030 
031 /**
032  * Title:        Apache Jakarta JMeter<br>
033  * Copyright:    Copyright (c) Apache<br>
034  * Company:        Apache<br>
035  * License:<br>
036  * <br>
037  * The license is at the top!<br>
038  * <br>
039  * Description:<br>
040  * <br>
041  * <p>
042  * Author:    pete<br>
043  * Version:     0.1<br>
044  * Created on:    Sep 30, 2003<br>
045  * Last Modified:    4:45:28 PM<br>
046  */
047 
048 public class BenchmarkP
049 {
050 
051     /**
052      * 
053      */
054     public BenchmarkP()
055     {
056         super();
057     }
058 
059     public static void main(String[] args)
060     {
061         if (args != null && args.length > 0)
062         {
063             String strurl = args[0];
064             boolean addLink = true;
065             if (args.length == 2)
066             {
067                 if (args[1].equals("f"))
068                 {
069                     addLink = false;
070                 }
071             }
072             if (strurl.indexOf("http") < 0)
073             {
074                 File input = new File(strurl);
075                 try
076                 {
Rate077                     strurl = input.toURL().toString();
078                     System.out.println("file converted to URL: " + args[0]);
079                 }
080                 catch (MalformedURLException e)
081                 {
082                     e.printStackTrace();
083                 }
084             }
085             try
086             {
087                 Parser parser = new Parser(strurl, new DefaultParserFeedback());
088 
089                 LinkScanner linkScanner =
090                     new LinkScanner(LinkTag.LINK_TAG_FILTER);
091                 if (addLink)
092                 {
093                     parser.addScanner(linkScanner);
094                 }
095                 parser.addScanner(
096                     linkScanner.createImageScanner(ImageTag.IMAGE_TAG_FILTER));
097                 parser.addScanner(new BodyScanner());
098                 long start = System.currentTimeMillis();
099                 for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
100                 {
101                     Node node = e.nextNode();
102                     if (node instanceof BodyTag)
103                     {
104                         BodyTag btag = (BodyTag) node;
105                         System.out.println(
106                             "body url: " + btag.getAttribute("background"));
107                         for (NodeIterator ee = btag.elements();
108                             ee.hasMoreNodes();
109                             )
110                         {
111                             Node cnode = ee.nextNode();
112                             if (cnode instanceof ImageTag)
113                             {
114                                 ImageTag iTag = (ImageTag) cnode;
115                                 System.out.println(
116                                     "image url: " + iTag.getImageURL());
117                             }
118                         }
119                     }
120                 }
121                 System.out.println(
122                     "Elapsed Time ms: " + (System.currentTimeMillis() - start));
123             }
124             catch (Exception e)
125             {
126                 e.printStackTrace();
127             }
128         }
129     }
130 }

            
All Examples in File:
Example
Line
Rating (found
useful by...)
77 0% of 0