Refresh some of the results of the program!

Source: Internet
Author: User
It's okay at night! You can log on to the logon path, but it seems that you have remembered cookies. After logging on several times, the number of logins remains unchanged. Continue the tobacco and alcohol cookies in another day! It is estimated that there is a timeout limit for cookies. --!? What's the problem! Package fresh; import java. Io. bufferedreader;
Import java. Io. ioexception;
Import java. Io. inputstream;
Import java. Io. inputstreamreader;
Import java. Io. outputstreamwriter;
Import java.net. malformedurlexception;
Import java.net. url;
Import java.net. urlconnection;
Import java.net. urlencoder ;/**
* @ Author WS
* @ Created at 2006-4-7 20:48:00
*/Public class testconnect {
Private Static string loginid = ""; Private Static string appid = ""; Private Static string Ru = ""; Private Static string FL = ""; Private Static string Ct = ""; private Static string Vr = ""; Private Static string SG = ""; Private Static string uid = ""; Private Static string passwd = ""; Private Static string utype = ""; private Static string query_str = ""; // http://passport.sohu.com/login.jsp
// Http: // localhost: 80/login. jsp
Private Static final string login_url = "http://passport.sohu.com/login.jsp ";/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
Try {
URL u = new URL (
"Http://alumni.chinaren.com/class/class_index.jsp? Classuuid = 2817034544986595867 ");
Urlconnection UC = U. openconnection ();
UC. setreadtimeout (20000 );
Inputstream raw = UC. getinputstream ();
Inputstreamreader ISR = new inputstreamreader (raw );
Bufferedreader BR = new bufferedreader (ISR );
String S;
Int I = 0;
While (S = Br. Readline ())! = NULL ){
I ++;
If (I = 410 ){
System. Out. println (s );
}
If (I> = 412 & I <= 417 ){
System. Out. println (s );
If (S. indexof ("appid")> 0 ){
Appid = getvalue (s );
} Else if (S. indexof ("Ru")> 0 ){
Ru = getvalue (s );
} Else if (S. indexof ("FL")> 0 ){
FL = getvalue (s );
} Else if (S. indexof ("CT")> 0 ){
Ct = getvalue (s );
} Else if (S. indexof ("Vr")> 0 ){
Vr = getvalue (s );
} Else if (S. indexof ("SG")> 0 ){
SG = getvalue (s );
}
Loginid = "******* @ chinaren.com ";
Uid = "*****";
Passwd = "*****";
Utype = "0 ";
} Else 'if (I> 418 ){
Break;
}
// Test
If (I == 412 & false ){
System. Out. println ("thisline:/N" + S );
System. Out. println (S. indexof ("value") + "and"
+ S. indexof ("/"> "));
System. Out. println (S. substring (S. indexof ("value =/" ") + 7, S
. Indexof ("/"> ")));
}
}
BR. Close ();
Sendlogon ();
} Catch (malformedurlexception e ){
E. printstacktrace ();
} Catch (ioexception e ){
E. printstacktrace ();
}
} Private Static void add (Object Name, object Value ){
If (! Query_str.trim (). Equals (""))
Query_str + = "&";
Query_str + = urlencoder. encode (name. tostring () + "="
+ Urlencoder. encode (value. tostring ());
} Private Static void sendlogon (){
Try {
URL u = new URL (login_url );
Urlconnection UC = U. openconnection ();
UC. setdooutput (true );
Outputstreamwriter out = new outputstreamwriter (UC
. Getoutputstream (), "ASCII ");
Add ("appid", appid );
Add ("Ru", Ru );
Add ("FL", FL );
Add ("CT", CT );
Add ("Vr", VR );
Add ("SG", SG );
Add ("uid", UID );
Add ("passwd", passwd );
Add ("utype", utype );
Add ("loginid", loginid );
Add ("uid", UID); Out. Write (query_str );
System. Out. println (query_str );
Out. Write ("/R/N ");
Out. Flush ();
Out. Close ();
Inputstream in = UC. getinputstream ();
Inputstreamreader ISR = new inputstreamreader (in );
Bufferedreader BR = new bufferedreader (ISR );
String SS;
While (Ss = Br. Readline ())! = NULL ){
System. Out. println (SS );
}
In. Close ();
} Catch (malformedurlexception e ){
E. printstacktrace ();
} Catch (ioexception e ){
E. printstacktrace ();
}
} Private Static string getvalue (string SRC ){
String TMP = "";
Try {
TMP = SRC
. Substring (SRC. indexof ("value =/" ") + 7, SRC. indexof ("/"> "));
} Catch (stringindexoutofboundsexception sition ){
System. Out. println ("wronglinenum! ");
}
Return TMP;
}
}

 

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.