Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: commands.conf-script for stock-prices



On Mon, Jan 06, 2003 at 09:56:59AM +0100, Robert Rafael Simons wrote:
> Robert Rafael Simons wrote:
> >P.S.: I hope the attachments will come through in a good way.
> Didn't :-(
and again (It's a long first work day :-))
> 
> 
> bash-script:
> ---------------
> #!/bin/bash
> 
> wget 
> http://tagesschau.ttweb2.net/search/searchResultsSecurities.asp?searchText=$1 
> -O - 2> /dev/null |
> java treat
> ---------------
> Java file:
> ---------------
import java.io.*;

class treat {
  public static void main(String args[]) {
     try {
	   BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
	   char ch=0;
	   int ret=1;
	   int state=0;
	   int td=0;
	   String blabla=new String("");
	   boolean ok=true;
	   while(ok&& ret>0) {
	     try{
	       char chars[];
	       chars=new char[30];
	       String string;
	       in.mark(30);
	       ret=in.read(chars,0,30);
	       string = (new String(chars)).toLowerCase();
	       in.reset();
	       switch(state){
	         case 0:// ""
		   if(string.startsWith("<tr bgcolor=")){//bgcolor=\"#EAEEFA\"")){
		     in.skip(12);         
		     state=1;
		     //System.out.print("<tr");
		   }else {
		     in.skip(1);
		     //System.out.print(""+chars[0]);
		   }
		   break;
		 case 1:// "<tr"
		   if(chars[0]!='>'){
		     in.skip(1);         
		     state=1;
		   }else {
		     state=2;
		     in.skip(1);
		     //System.out.print(">");
		   }
		   break;
		 case 2:// "<tr.*>"
		   if(string.startsWith("<td")){
		     in.skip(12);         
		     state=3;
		     //System.out.print("<td");
		   }
		   else if(string.startsWith("</tr>")){
		     in.skip(5);         
		     state=0;
		     //System.out.println("</tr>");
		     td=0;
		   }else {
		     state=2;
		     in.skip(1);
		    }
		   break;		 
		 case 3:// "<tr><td"
		   if(chars[0]!='>'){
		     in.skip(1);         
		     state=3;
		   }else {
		     state=4;
		     in.skip(1);
		     //System.out.print(">");
		     blabla=new String("");
		   }
		   break;
		 case 4:// "<tr.*><td>"
		   if(string.startsWith("</td>")){
		     td++;
		     in.skip(5);         
		     state=2;
		     if(td==2)System.out.print(blabla+": ");
		     if(td==5)System.out.print(blabla+" last: ");
		     if(td==8)System.out.println(blabla);
		   }else {
		     state=4;
		     blabla=new String(blabla+chars[0]);
		     in.skip(1);
		    }
		   break;		 
	       }
	     }catch(IOException ioe){
	        ok=false;
	     }
	   }
	}catch(Exception e){
	}
  }
  
}
> ---------------

Gruss Robert


-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index