random web pages loader

S

SimonP

does any one here know how i could implement a java program to
automaticaly load random or listed web pages. I thought it would be
cool to have my laptop displaying a load of pages automatically.

Simon
 
R

Roedy Green

does any one here know how i could implement a java program to
automaticaly load random or listed web pages. I thought it would be
cool to have my laptop displaying a load of pages automatically.

I do it with a java macro that compose web pages statically.
here is the code.

package com.mindprod.htmlmacros;
import java.io.File;
import java.util.Random;

public class RandomLink implements Macro
{
/**
* Generates a link to a randomly chose url,
* which could be as small as a single letter or even "".
* invoked with:
* <!-- macro RandomLink this.html http://mindprod.com/that.html
.../else.html -->
*
* @param parms takes variable number of parms, reprsenting
possible choice strings to generate.
* @param fileBeingProcessed
* @return one of the choices.
*/
public String expand ( String[] parms, File fileBeingProcessed,
boolean quiet )
{
if ( ! quiet )
{
System.out.print( "R" );
}
if ( parms.length == 0 )
{
throw new IllegalArgumentException ( "RandomLink needs list
of choices." );
}
return expand( parms );

}

/**
* expand RandomLink macro guts
*
* @param choices array of possible choices to choose from
* @return on of the choice strings, randomly chosen
*/
public String expand ( String[] choices )
{
Random wheel = new Random( );
int pick = wheel.nextInt( choices.length );
return "<a href=\"" +choices[ pick ] + "\">";
}

}


If want an applet that loads a random page, see
http://mindprod.com/jgloss/applet.html#LOADING
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top