scrape.jsp
来自「jakarta-taglibs」· JSP 代码 · 共 48 行
JSP
48 行
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<%@ taglib uri="http://jakarta.apache.org/taglibs/scrape-1.0" prefix="scrp" %>
<head>
<title>Example JSP using scrape taglib</title>
</head>
<body bgcolor="#FFFFFF">
<scrp:page url="http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/city/mo/columbia.txt" time="11">
<scrp:scrape id="weather1" begin="<PRE>" end="</PRE>" anchors="true"/>
<scrp:scrape id="weather2" begin="<PRE>" end="</PRE>" anchors="false"/>
<scrp:scrape id="weather3" begin="<PRE>" end="</PRE>" anchors="false" strip="true"/>
</scrp:page>
<h3 align="center">Weather Quote</h3><br/><br/>
<p><b>Example #1</b><br/>
The example below scrapes the page for the
<a href="http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/city/mo/columbia.txt">Columbia,
Missouri weather forecast</a> from the <a href="http://weather.noaa.gov/">National Weather Service</a> site. In this scrape, the
<b>anchors</b> attribute was set to true, and the <b>begin</b> and <b>end</b> anchor attributes
were set to the <PRE> and </PRE> tags that surround the forecast.
</p>
<scrp:result scrape="weather1"/>
<hr/>
<p><b>Example #2</b><br/>
This example scrapes the same page as the first example and uses the same anchors,
but in this case the <b>anchors</b> attribute was set to false so that the anchors are stripped from
the scrape result. Browsers typically treat text within <PRE> tags with a monospaced font
and line breaks in the HTML are retained. Since the <PRE> and </PRE> tags are the anchors and they
are removed from the scrape result, the formatting is noticeably different.
</p>
<scrp:result scrape="weather2"/>
<hr/>
<p><b>Example #3</b><br/>
This example scrapes the same page as the first two examples and uses the same anchors,
but in this case the <b>anchors</b> attribute was set to false and the <b>strip</b> attribute was set to true so that the anchors and HTML tags are stripped from the scrape result.
</p>
<scrp:result scrape="weather3"/>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?