Include Topics and Web Pages Using %INCLUDE{...}% Variable

Use the %INCLUDE{...}% variable to embed the content of another topic or web page inside a TWiki topic. The whole content or only parts of a page can be included.

Syntax

%INCLUDE{"page" pattern="reg-exp"}%

  • "page":
    The nameless parameter specifies the page to include. It is
    • The name of a topic located in the current web, i.e. %INCLUDE{"WebNotify"}%
    • A Web.Topic name specifying a topic in another web, i.e. %INCLUDE{"TWiki.TWikiWebsTable"}%
    • A full qualified URL with http protocol, domain name and optional port number, i.e. %INCLUDE{"http://twiki.org:80/index.html"}%. Supported content types are text/html and text/plain. The full page is included by default, but the HTML header and scripts are stripped in case it is a web page.

  • pattern="reg-exp":
    The pattern parameter is optional and allows you to extract some parts of a web page. Specify a RegularExpression that scans from start ('^') to end and contains the text you want to keep in parenthesis, i.e. pattern="^.*?(from here.*?to here).*". You need to make sure that the integrity of a web page is not compromised, i.e. if you include a table make sure to include everything including the table end tag.

Note: All text of a topic is included unless you specify %STARTINCLUDE%, %STOPINCLUDE% and/or a pattern parameter.

Usage Examples

1. Display regression test results in a TWiki page

  <pre>
  %INCLUDEURL{"http://domain/~qa/v1.1/REDTest.log.txt"}%
  </pre>

2. Display Yahoo's robot.txt file

  • You type:
    • %INCLUDE{"http://www.yahoo.com/robots.txt"}%
  • You get:

<center>
<table width=650 cellpadding=0 cellspacing=2 border=0>
   <tr>
   <td width=1% valign=top><a href="http://www.yahoo.com/404/*http://www.yahoo.com"><img src=http://us.i1.yimg.com/us.yimg.com/i/yahoo.gif width=147 height=31 border=0 alt="Yahoo"></a></td>
   <td align=right><font face=arial size=-1><a href="http://www.yahoo.com/404/*http://www.yahoo.com">Yahoo!</a> - <a href="http://www.yahoo.com/404/*http://help.yahoo.com">Help</a></font><hr size=1 noshade></td>
   </tr>
</table>
<br><br>
<table width=500 cellpadding=7 cellspacing=0 border=0>
<tr><td align=center><font face=arial size=+1><b>Sorry, the page you requested was not found.</b></font></td></tr>
<tr><td><font face=arial size=-1>Please check the URL for proper spelling and capitalization. If you're having trouble locating a destination on Yahoo!, try visiting the <b><a href="http://www.yahoo.com/404/*http://www.yahoo.com">Yahoo! home page</a></b> or look through a list of <b><a href="http://www.yahoo.com/404/*http://docs.yahoo.com/docs/family/more.html">Yahoo!'s online services</a></b>. Also, you may find what you're looking for if you try searching below.</font>
</td></tr>
<tr><td>
   <table width=100% cellpadding=0 cellspacing=0 border=0 bgcolor=cccccc><tr><td height=1></td></tr></table>
   <table width=100% cellpadding=10 cellspacing=0 border=0 bgcolor=eeeeee>
   <tr><td align=center>
   <form name=s1 style="margin-bottom:0" action="http://www.yahoo.com/404/*-http://search.yahoo.com/search">
   <table cellpadding=0 cellspacing=0 border=0><tr><td>
   <input type=text size=30 name=p title="enter search terms here">&nbsp;<input type=submit value=Search>&nbsp;&nbsp;</td><td><font face=arial size=-2>&#149;&nbsp;<a href="http://www.yahoo.com/404/*http://search.yahoo.com/search/options?p=">advanced search</a><br>&#149;&nbsp;<a href="http://www.yahoo.com/404/*http://buzz.yahoo.com">most popular</a></font></td></tr></table></form>
   
   </td></tr>
   </table>
   <table width=100% cellpadding=0 cellspacing=0 border=0 bgcolor=cccccc><tr><td height=1></td></tr></table>

</td></tr>
<tr><td align=center><font face=arial size=-1>Please try <b><a href="http://www.yahoo.com/404/*http://help.yahoo.com">Yahoo! Help Central</a></b> if you need more assistance.</font></td></tr>
</table>
<br>
<hr size=1 noshade width=650>
<font face=arial size=-2>Copyright &copy; 2004 Yahoo! Inc. All rights reserved. <a href="http://www.yahoo.com/404/*http://privacy.yahoo.com">Privacy Policy</a> - <a href="http://www.yahoo.com/404/*http://docs.yahoo.com/info/terms/">Terms of Service</a></font>

</center>
<!-- f62.us.www.ird.yahoo.com uncompressed Fri Sep  5 22:10:51 GMT 2008 -->

3. Display the SUNW stock quote in a TWiki page

  • You type:
    • SUNW: %INCLUDE{"http://finance.yahoo.com/q?s=SUNW&d=v1&o=t" pattern="^.*?>SUNW</a>[^<]+(.*?)\s+\S+\s+<small.*"}%
  • You get:
    • SUNW:

4. Display the temperature in San Francisco

  • You type:
    • San Francisco: %INCLUDE{"http://weather.yahoo.com/forecast/San_Francisco_CA_US_f.html" pattern="^.*?([0-9]+\&ordm\;F).*"}%
  • You get:
    • San Francisco:

See also other TWikiVariables.

-- PeterThoeny? - 25 Jun 2001