`
olife
  • 浏览: 76528 次
  • 性别: Icon_minigender_1
  • 来自: SKY
文章分类
社区版块
存档分类
最新评论

[Java]send Get Message to a website

阅读更多
import java.io.*;
import java.net.*;
import java.util.Scanner;

public class RandomWeb {
   
   public static void main(String args[]){
    
    Scanner scan = new Scanner(System.in);
    System.out.println("Your Website:");
    String siteUrl = scan.next();
    System.out.println("Your Range of Number:");
    String range[] = scan.next().split(",");
    System.out.println("Setting Wait:");
    int slpTime = scan.nextInt();
    
    int rangeStart = Integer.parseInt(range[0]);
    int rangeEnd = Integer.parseInt(range[1]);
    
    if(rangeStart > rangeEnd){
      System.out.println("Range Error!");
      return;
    }
    for(int i = rangeStart ; i < rangeEnd ; i++){
      
      Thread th = new Thread(new GetHtml(siteUrl.replaceAll("###",String.valueOf(rangeStart)),slpTime));  
        th.start(); 
    }
    
   }

  public static class GetHtml implements Runnable{

   String urlToRead;
   int slpTime;
   GetHtml(String urlToRead,int slpTime){
    this.urlToRead = urlToRead;
    this.slpTime = slpTime;
   }
   
   
   public void run() {  
      URL url; // The URL to read
      HttpURLConnection conn; // The actual connection to the web page
      BufferedReader rd; // Used to read results from the web page
      String line; // An individual line of the web page HTML
      String result = ""; // A long string containing all the HTML
      try {
         url = new URL(urlToRead);
         conn = (HttpURLConnection) url.openConnection();
         conn.setRequestMethod("GET");
         rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
         while ((line = rd.readLine()) != null) {
            result += line;
         }
         rd.close();
      } catch (Exception e) {
          //System.out.println("Web site not found!!");
         e.printStackTrace();
      }

      try{
      Thread.sleep(slpTime*1000);
      }catch(Exception e){
        System.out.println("wait time error!!");
      }  
   }
   
}

}



分享到:
评论

相关推荐

    Practical Protocols XMPP(PACKT,2016)

    Install and configure an XMPP server and use it to connect from a traditional desktop client and send a message Build a simple server-side application that will respond to messages from our logged in ...

    Practical.XMPP.1785287982

    Install and configure an XMPP server and use it to connect from a traditional desktop client and send a message Build a simple server-side application that will respond to messages from our logged in ...

    plug-In PHP- 100 Power Solutions

    This practical guide gives you 100 ready-to-run PHP functions for solving most of the main problems you encounter when building a dynamic website with PHP. Every plug-in in the book offers a complete ...

    VB编程资源大全(英文源码 网络)

    You can send messages with a client/server type setup.&lt;END&gt;&lt;br&gt;57 , al40.zip Apparently, if you use AOL to connect to the Internet and you do not touch it for 45 minutes it will timeout and drop ...

    C# Game Programming Cookbook for Unity 3D - 2014

    4.3.1 A Simple Spawn Controller..................................49 4.3.1.1 Script Breakdown................................52 4.3.2 Trigger Spawner...........................................56 4.3.3 ...

    ICS delphixe10源码版

    send cash (Euro currency or US Dollars) in an envelop to my street address or buy a gift certificate at Amazon in the UK. I will then use it to buy books. Here is the direct URL at Amazon UK (nearest ...

    Clever Internet Suite (SRC) v9.1.0.0

    The connected client cannot get back to the root folder after navigating to a subfolder - fixed. Known problems and restrictions FTP client and server - data connection uses IpV4 protocol only. Socks...

    ProjectOZ

    MapView - Map process addresses to section offsets Wait/Reply port - Receive/Send message to port &lt;br&gt;SPACE Implementation -------------------- CPUs are implemented using NT threads....

    .htaccess

    only allowing people using a particular ISP to get into a certian directory) or you may want to ban certian IP addresses (for example, keeping disruptive memembers out of your message boards)....

    erlang日志应用log4erl(非sasl)

    To compile & install log4erl, download source from google code's website (http://code.google.com/p/log4erl/) or from svn: $&gt; svn checkout http://log4erl.googlecode.com/svn/trunk/ log4erl or from ...

    Radmin自动登录器v3.0-多国语言绿色版-Release1-20150615

    (A)启动Excel,选择菜单“数据-&gt;导入外部数据-&gt;导入数据”,选择RadminM.txt文件; (B)文本导入向导第1步,直接单击“下一步”; (C)第2步必须选中“逗号”分隔符,再单击“下一步”; (D)第3步必须将所有18列都...

    Radmin自动登录器v3.0

    (A)启动Excel,选择菜单“数据-&gt;导入外部数据-&gt;导入数据”,选择RadminM.txt文件; (B)文本导入向导第1步,直接单击“下一步”; (C)第2步必须选中“逗号”分隔符,再单击“下一步”; (D)第3步必须将所有18列都...

    Bochs - The cross platform IA-32 (x86) emulator

    - new hdimage method get_capabilities() that can return special flags - vmware3, vmware4 and vvfat classes now return HDIMAGE_HAS_GEOMETRY flag - other disk image modes by default return HDIMAGE_...

Global site tag (gtag.js) - Google Analytics