java程序,向网站发送垃圾留言
文件名:HttpPost.java
描述: 有个网站老是给我发Email,所以就写了个小程序自动往留言本里面插入数据
作者:慈勤强
Email:cqq1978@Gmail.com
最后修改:2004-10-08
**/
import java.net.*;
import java.io.*;
class HttpPost extends Thread
{
private String strUrl;
private String strPostData;
public void setUrl(String str)
{
strUrl=str;
}
public String getUrl()
{
return strUrl;
}
public void setPostData(String str)
{
strPostData = str;
}
public String getPostData()
{
return strPostData;
}
public void doHttpPost()
{
String s,s1;
s=getUrl();
s1=getPostData();
if(s!=null)
{
try
{
URL url = new URL(s);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(s1);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
wr.close();
rd.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
public void run()
{
for(int i=1;i<20;i++)
{
HttpPost hp=new HttpPost();
hp.setUrl("http://www.hdptex.com/liuyan/savedata.asp");
hp.setPostData("txtname=茅山道人&txtEmail=s&txtTitle=不可不看&txtContent=http://blog.csdn.net/cqq");
hp.doHttpPost();
System.out.println("" + i);
}
}
public static void main(String[] args)
{
try
{
Thread[] t=new Thread[2];
for(int i=0;i<t.length;i++)
{
t[i]=new HttpPost();
t[i].start();
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
Tags:
作者:佚名评论内容只代表网友观点,与本站立场无关!
评论摘要(共 0 条,得分 0 分,平均 0 分)
查看完整评论