Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > random web pages loader

Reply
Thread Tools

random web pages loader

 
 
SimonP
Guest
Posts: n/a
 
      05-26-2004
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
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      05-26-2004
On 26 May 2004 15:09:46 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (SimonP) wrote or
quoted :

>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

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Library class loader (setting system class loader parent) Karsten Wutzke Java 0 06-29-2007 04:44 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net 5 01-10-2007 10:50 AM
Using Web.config's <system.web><pages><controls><add /></controls></pages></system.web> To Register UserControls Nathan Sokalski ASP .Net Building Controls 4 12-21-2006 02:50 AM



Advertisments