Class HTMLParser
java.lang.Object
org.apache.jmeter.protocol.http.parser.HTMLParser
- Direct Known Subclasses:
JsoupBasedHtmlParser
HtmlParsers can parse HTML content to obtain URLs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringprotected static final Stringprotected static final Patternstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor to prevent instantiation except from within subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected FloatextractIEVersion(String userAgent) getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, String encoding) Get the URLs for all the resources that a browser would automatically download following the download of the HTML content, that is: images, stylesheets, javascript files, applets, etc...getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, Collection<URLString> coll, String encoding) Get the URLs for all the resources that a browser would automatically download following the download of the HTML content, that is: images, stylesheets, javascript files, applets, etc...getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, URLCollection coll, String encoding) Get the URLs for all the resources that a browser would automatically download following the download of the HTML content, that is: images, stylesheets, javascript files, applets, etc...static final HTMLParserstatic final HTMLParserprotected final booleanisEnableConditionalComments(Float ieVersion) protected booleanParsers should over-ride this method if the parser class is re-usable, in which case the class will be cached for the next getParser() call.
-
Field Details
-
ATT_BACKGROUND
- See Also:
-
ATT_CODE
- See Also:
-
ATT_CODEBASE
- See Also:
-
ATT_DATA
- See Also:
-
ATT_HREF
- See Also:
-
ATT_REL
- See Also:
-
ATT_SRC
- See Also:
-
ATT_STYLE
- See Also:
-
ATT_TYPE
- See Also:
-
ATT_IS_IMAGE
- See Also:
-
TAG_APPLET
- See Also:
-
TAG_BASE
- See Also:
-
TAG_BGSOUND
- See Also:
-
TAG_BODY
- See Also:
-
TAG_EMBED
- See Also:
-
TAG_FRAME
- See Also:
-
TAG_IFRAME
- See Also:
-
TAG_IMAGE
- See Also:
-
TAG_INPUT
- See Also:
-
TAG_LINK
- See Also:
-
TAG_OBJECT
- See Also:
-
TAG_SCRIPT
- See Also:
-
STYLESHEET
- See Also:
-
IE_UA
- See Also:
-
IE_UA_PATTERN
-
PARSER_CLASSNAME
- See Also:
-
DEFAULT_PARSER
- See Also:
-
-
Constructor Details
-
HTMLParser
protected HTMLParser()Protected constructor to prevent instantiation except from within subclasses.
-
-
Method Details
-
getParser
-
getParser
-
getEmbeddedResourceURLs
public Iterator<URL> getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, String encoding) throws HTMLParseException Get the URLs for all the resources that a browser would automatically download following the download of the HTML content, that is: images, stylesheets, javascript files, applets, etc...URLs should not appear twice in the returned iterator.
Malformed URLs can be reported to the caller by having the Iterator return the corresponding RL String. Overall problems parsing the html should be reported by throwing an HTMLParseException.
- Parameters:
userAgent- User Agenthtml- HTML codebaseUrl- Base URL from which the HTML code was obtainedencoding- Charset- Returns:
- an Iterator for the resource URLs
- Throws:
HTMLParseException- when parsing thehtmlfails
-
getEmbeddedResourceURLs
public abstract Iterator<URL> getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, URLCollection coll, String encoding) throws HTMLParseException Get the URLs for all the resources that a browser would automatically download following the download of the HTML content, that is: images, stylesheets, javascript files, applets, etc...All URLs should be added to the Collection.
Malformed URLs can be reported to the caller by having the Iterator return the corresponding RL String. Overall problems parsing the html should be reported by throwing an HTMLParseException.
N.B. The Iterator returns URLs, but the Collection will contain objects of class URLString.
- Parameters:
userAgent- User Agenthtml- HTML codebaseUrl- Base URL from which the HTML code was obtainedcoll- URLCollectionencoding- Charset- Returns:
- an Iterator for the resource URLs
- Throws:
HTMLParseException- when parsing thehtmlfails
-
getEmbeddedResourceURLs
public Iterator<URL> getEmbeddedResourceURLs(String userAgent, byte[] html, URL baseUrl, Collection<URLString> coll, String encoding) throws HTMLParseException Get the URLs for all the resources that a browser would automatically download following the download of the HTML content, that is: images, stylesheets, javascript files, applets, etc...N.B. The Iterator returns URLs, but the Collection will contain objects of class URLString.
- Parameters:
userAgent- User Agenthtml- HTML codebaseUrl- Base URL from which the HTML code was obtainedcoll- Collection - will contain URLString objects, not URLsencoding- Charset- Returns:
- an Iterator for the resource URLs
- Throws:
HTMLParseException- when parsing thehtmlfails
-
isReusable
protected boolean isReusable()Parsers should over-ride this method if the parser class is re-usable, in which case the class will be cached for the next getParser() call.- Returns:
- true if the Parser is reusable
-
isEnableConditionalComments
- Parameters:
ieVersion- Float IE version- Returns:
- true if IE version < IE v10
-
extractIEVersion
-