Java automatically publishes information in Zhongguancun second-hand market
Last Update:2017-02-28
Source: Internet
Author: User
/**
FileName: Zol.java
Description: Automatic in Zhongguancun second-hand market submission of information procedures
Author: Ci Qin Qiang
email:cqq1978@gmail.com
**/
import java.io.*;
import java.net.*;
class Zol
{
public String strcookie= "";
Private String Login ()//get cookie
{
String strurl= "http://www.zol.com.cn/user/login.php";
String strpwd= "Sssssssss"; Registered User name
String struser= "dddddddd"; Password
String strpostdata= "user=" +struser+ "&password=" +STRPWD;
String strtmp;
Try
{
url url = new URL (strurl);
URLConnection conn = Url.openconnection ();
Conn.setdooutput (TRUE);
OutputStreamWriter WR = new OutputStreamWriter (Conn.getoutputstream ());
Wr.write (Strpostdata);
Wr.flush ();
BufferedReader rd = new BufferedReader (New InputStreamReader (Conn.getinputstream ()));
Wr.close ();
Rd.close ();
stringbuffer sb=new StringBuffer ("");
for (int i=0;; i++)
{
String headername = Conn.getheaderfieldkey (i);
String headervalue = Conn.getheaderfield (i);
if (headername!=null && headername.equalsignorecase ("Set-cookie"))
{
int J=headervalue.indexof (";");
sb.append (headervalue.substring (0,j) + ";");
}
if (headername = = NULL && Headervalue = null)
{
break;
}
}
return sb.tostring ();
}
catch (Exception e)
{
return "err";
}
}
private String doPost ()
{
String strurl= "http://flea.zol.com.cn/input_save.php";
String s1= "game_board=0&"; S1 A detailed description of the information submitted, you can refer to the
s1=s1+ "title=http://blog.csdn.net/cqq&";
s1=s1+ "categorynumber=5&";
s1=s1+ "photo_file=&";
s1=s1+ "subcategorynumber=70&";
s1=s1+ "areanumber=2&";
s1=s1+ "trademodenumber=1&";
s1=s1+ "hownew=f&";
s1=s1+ "price=111&";
s1=s1+ "endtime=8&";
s1=s1+ "brief= This information from HTTP://BLOG.CSDN.NET/CQQ automatically issued &";
s1=s1+ "linkman=cqq&";
s1=s1+ "phone=12345678&";
s1=s1+ "Email=sss@sss.net";
String SS;
stringbuffer s2=new StringBuffer ("");
Try
{
url url = new URL (strurl);
URLConnection conn = Url.openconnection ();
conn.setrequestproperty ("Cookie", Login ());
Conn.setdooutput (TRUE);
OutputStreamWriter WR = new OutputStreamWriter (Conn.getoutputstream ());
Wr.write (S1);
Wr.flush ();
BufferedReader rd = new BufferedReader (New InputStreamReader (Conn.getinputstream ()));
while ((Ss=rd.readline ())!=null)
{
s2.append (ss+ "\ r \ n");
}
Wr.close ();
Rd.close ();
return s2.tostring ();
}
catch (Exception e)
{
return "error";
}
}
public static void Main (string[] args) throws Exception
{
zol z=new zol ();
System.out.println (Z.dopost ());
}
}