熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

Java趣味Java網絡機器人

2013-11-23 19:23:35  來源: Java核心技術 

  package auto;
  import *;
  import javasql*;
  import javaio*;
  import javautil*;
  //import db*;
  public class test extends Thread{
  URL weburl;
  String urladdr;
  public test()
  {}
  public test(String urladdrURL weburl)
  {
  thisurladdr=urladdr;
  thisweburl=weburl;
  }
  public test(String urladdr)
  {
  try{
  thisurladdr=urladdr;
  //weburl=new URL(urladdr);
  thisstart();
  }
  catch(Exception e){Systemoutprintln(etoString());}
  }
  public InputStream getStream(String url)
  {
  try{
  //urladdr=url;
  URL tempurl=new URL(url);
  
  return tempurlopenStream();
  }catch(Exception e){Systemoutprintln(hello);}
  return null;
  }
  public void run()
  {
  while(true)
  { try{
  getStream(urladdr);
  Threadsleep();
  }catch(Exception e){}
  }
  }
  public String getStr(InputStream in)
  {
  try{
  StringBuffer temp=null;
  BufferedReader buffer=new BufferedReader(new InputStreamReader(in));
  String tempstr=;
  String strsum=;
  while ((tempstr=bufferreadLine())!=null)
  {
  strsum=strsum+tempstr;
  
  }
  bufferclose();
  //inclose();
  return strsum;}
  catch(Exception e){Systemoutprintln(shit);
  }
  return ;
  }
  public String getMTVURL(String html)
  { try{
  String temp=htmlsubstring(htmllastIndexOf(/)+);
  temp=tempsubstring(tempindexOf(\));
  temp=?Id=;+temp;
  
  temp=temptrim();
  
  
  return temp; }catch(Exception e){Systemoutprintln(etoString());}
  return null;
  }
  public String getMTVname(String html)
  {
  try{
  String temp=htmlsubstring(htmlindexOf(作品名)+);
  temp=tempsubstring(tempindexOf());
  temp=temptrim();
  return temp;}
  catch(Exception e){Systemoutprintln(hello);}
  return null;
  }
  public void insertdb(String MTVURLString MTVname)
  {
  // DBoperate writer=new DBoperate();
  // String insert=insert into mtvList(mtvnamemtvurl)values(+MTVname++MTVURL+);
  // writerexesql(insert);
  }
  public void getover()
  {
  InputStream in=getStream(urladdr);
  String content=getStr(in);
  String url=getMTVURL(content);
  String name=getMTVname(content);
  insertdb(urlname);
  }
  public static void main(String[] avg)
  {
  for(;;)
  {
  
  try{
  test look=new test(;);
  lookgetStream(lookurladdr)close();
  Threadsleep();
  }
  catch(Exception e){
  Systemoutprintln(etoString());
  continue;}}
  }
  }

From:http://tw.wingwit.com/Article/program/Java/hx/201311/26768.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.