View script | License | Download documentation as: HTML or editable | Download script | History |
[0.048] 29.727k
Documentation for: webcheck.rUsage document for the %webcheck.r1. Using webcheck.r1.1. Setup required%webcheck.r requires some setup before it is useable. Copy the library script to a local directory with the command listed below. It is listed below to keep the floating table of contents from obscuring the command. Edit the local %webcheck.r. Change the web page you wish to check and the email address for sending results. If you are using REBOL/View, just use the builtin editor function. For REBOL/Core, you will need to run an external editor, such as notepad. Getting a local copy using REBOL: >> write %webcheck.r read http://www.rebol.org/cgi-bin/cgiwrap/rebol/download-a-script.r?script-name=webcheck.ror you use your browser and the rebol.org download script options. 1.2. Standard REBOL network settingsThere is a standard utility that holds some basic REBOL configuration information. set-net takes a block of information so that REBOL knows how to route mail and for other internet connections. The REBOL/View Viewtop main User menu allows access to these settings or you can edit the default %user.r file and change the set-net information. >> help set-net USAGE: SET-NET settings DESCRIPTION: Network setup. All values after default are optional. Words OK for server names. SET-NET is a function value. ARGUMENTS: settings -- [ email-addr default-server pop-server proxy-server proxy-port-id proxy-type esmtp-user esmtp-pass ] (Type: block) The first two setting are for sending mail, the third is for reading mail, then there are proxy connection settings and then two settings for authenticated mail username and password. 1.3. Running %webcheck.rAfter the configuration is all set up, using webcheck is simple. Just do it. >> do %webcheck.r This will examine the web page, see if its checksum matches a previous check and, if a change is detected, mail the new page to the address specified after the send function. This is the main reason that this script needs modification. Sending mail to luke@rebol.com is not much good to anybody. 1.4. Support file created%webcheck.r creates a summary file %page-sum.r. This file is used to determine if the checked page has changed since the last time you ran %webcheck.r.2. What you can learnThis script has a few learning goodies in it. 2.1. Reading web pagesFirst and foremost, the ease of reading a web page. 2.2. ChecksumsREBOL comes with a builtin checksum function. Checksums are a fairly high level computer science concept that scans a piece of data and returns a single value that is (usually) the sum of all the bits squished into a smallish number. 2.3. if with anyREBOL provides a complete set of looping and control structures, common to most programming environments. REBOL extends these normal control structures with a nifty little any sequence. The native any word, evaluates a block of expressions and, working like a shortcut logical or, returns the first value that is not FALSE or NONE. In the case of the %webcheck.r script, the following occurs:
Now the if statement will test to see if any returned true or false. If it was true, (no %page-sum.r exists, or the checksums were different), the block with the print, save, and send will execute. This will save the checksum value if this is the first time that you have run %webcheck.r. If the result of the any block was false (%page-sum.r exists and the checksums were the same), nothing else will happen. That means the page is the same and there is no sense informing anyone or saving the checksum value, since it is the same. 2.4. print with blocksThe REBOL print statement can take many different datatypes. In this case the data is in a block and all values in the block are printed after being evaluated. In REBOL for printing, this type of evaluation is termed reduce. The quoted string "page changed" evaluates to itself, a string! and now evaluates to the current date and time. 2.5. load and saveREBOL has powerful but easy to use save and load functionality. The save function produces output that REBOL knows how to load directly. 3. Some Definitions
4. Also worth a lookThere is a full suite of scripts that demonstrate how easy it is to use the HTTP url! (or "the web" ) features in REBOL. These features are one of the central design goals of the REBOL scripting environment. These sample scripts highlight the ease of using internet resources with REBOL. 5. List of tutorial scripts in the web category
6. A script you have to check out
7. More in-depth scripts
7.1. Other web related scriptsdealing with web related REBOL programming that you can find in the rebol.org library. There are also complete suites for FTP, HTML, CGI, and many others.8. Credits
|