Java automatically publishes information in Zhongguancun second-hand market

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 ());


}


}

















Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.