I believe there are also many friends in kaixin.com, but to make it easier, I developed a kaixin.com auxiliary tool that can be operated automatically.
Now, in order to develop more powerful functions, I want to explain the principle and all the class libraries I have encapsulated. I hope you can join me to develop more ins!
Preparation tool: wsockexpert (for packet capture)
Principle: analyzes all operation connections of kaixin.com and simulates requests through a program to Perform Batch operations!
Today, we use kaixinnet login as an example and simulate login using a program.
Select the listener page and log in from the browser.
After clicking the "log in" button, the packet capture program will change. Because we interacted with kaixin.com server just now and needed to send data to the outside, we obtained the following results through packet capture data:
Post/login. php HTTP/1.1
Accept: Application/X-Shockwave-flash, image/GIF, image/X-xbitmap, image/JPEG, image/pjpeg, application/vnd. MS-Excel, application/vnd. MS-PowerPoint, application/MSWord ,*/*
Referer: http://www.kaixin001.com/
Accept-language: ZH-CN
Content-Type: Application/X-WWW-form-urlencoded
UA-CPU: x86
Accept-encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; sv1);. Net CLR 2.0.50727; CBA)
HOST: http://www.kaixin001.com/
Content-Length: 48
Connection: keep-alive
Cache-control: No-Cache
COOKIE: _ uid = 2121099; serverid = _ srv134-110 _
Mailto: url = % 2f & amp; email = dirain ** @ yahoo.cn & amp; Password = 19920226
/Login. php is the login request address. All connections should be http://www.kaixin001.com/login/login.php.
The lowest mailto: url = % 2f & amp; email = dirain ** @ yahoo.cn & amp; Password = 19920226 should be the passed parameter. We can see that, only the account and password parameters are submitted, and the request type is post.
With this information, you can simulate a request through the webrequest of C # To implement the login operation. The Code is also very simple.
Request Simulation Method
Simulate POST request
/// <Summary>
/// Send a POST request
/// </Summary>
/// <Param name = "url"> request address </param>
/// <Param name = "postdata"> parameter </param>
/// <Returns> </returns>
Public webresponse dopost (string URL, string postdata)
{
Try
{
System. gc. Collect ();
Thread. Sleep (this. Defer );
Byte [] parambyte = encoding. utf8.getbytes (postdata); // convert
Httpwebrequest webrequest = (httpwebrequest) webrequest. Create (URL );
Webrequest. method = "Post ";
Webrequest. contenttype = "application/X-WWW-form-urlencoded ";
Webrequest. Referer = "http://www.kaixin001.com/app/app.php? Aid = 1040 ";
Webrequest. accept = "application/X-Shockwave-flash, image/GIF, image/X-xbitmap, image/JPEG, image/pjpeg, application/vnd. MS-Excel, application/vnd. MS-PowerPoint, application/MSWord, application/X-Silverlight ,*/*";
Webrequest. useragent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;. Net CLR 2.0.50727; CBA )";
Webrequest. contentlength = parambyte. length;
Webrequest. cookiecontainer = This. Cookies;
// Webrequest. Timeout = 5000;
Stream newstream = webrequest. getrequeststream ();
Newstream. Write (parambyte, 0, parambyte. Length); // write Parameters
Newstream. Close ();
Return webrequest. getresponse ();
}
Catch (exception CE)
{
Throw CE;
}
}
When simulating a request, you must note that the cookie is synchronized; otherwise, the session cannot be maintained.
Webrequest. cookiecontainer = This. Cookies;
This statement is the key code used to maintain the session. This. Cookie is a non-local variable, so that the cookie of the previous operation can be used for each call.
Code
/// <Summary>
/// Cookie related to the request (used to maintain the session)
/// </Summary>
Protected cookiecontainer cookies = new cookiecontainer ();
As long as the cookiecontainer attribute of the webrequest object is assigned to the declared cookiecontainer object during each request, instead of re-instantiating it.
Log on to kaixin.com
Log on to kaixin.com
/// <Summary>
/// Log on to kaixin.com
/// </Summary>
/// <Param name = "Account"> User Name </param>
/// <Param name = "password"> password </param>
/// <Returns> User Personal Information </returns>
Public Virtual userinfoentity login (string account, string password)
{
Try
{
// Splice Login Parameters
String Param = "url =/home/& invisible_mode = 0 & Email =" + account + "& Password =" + password;
Webresponse response = This. dopost ("http://www.kaixin001.com/login/login.php", Param );
Streamreader = new streamreader (response. getresponsestream (), encoding. utf8 );
// If the returned address is the home page, the logon is successful.
If (response. responseuri. tostring () = "http://www.kaixin001.com/home ")
{
// Read the returned stream
String body = streamreader. readtoend ();
// If the following information exists, the logon fails.
If (body. indexof ("the account or password is not correct! Retry once? ")! =-1)
{
Return NULL;
}
Else
{
// After successful login, run
//
}
}
Else
{
Response. Close ();
Streamreader. Close ();
}
}
Catch
{
}
}
This is a simple simulated request login code. In fact, it is an auxiliary tool for web programs. What is important is to analyze data, the most important step in this example is to use the packet capture tool to capture the submission method and Transfer Parameters of kaixin.com. If you do not need a packet capture tool to capture, you can also analyze the HTML form to obtain the transfer method, but this will be very troublesome.
To sum up, the process is actually very simple. Analyze the URL submitted to the server, simulate the request through the program, and then obtain the server response results. We can achieve the desired effect by extracting the webpage content.
I personally have made a perfect kaixinnet Helper Program and open source code. I hope more friends can join my forum, my helper program will provide all core class library documents and use cases. If you are interested, you can come to my forum to get the class libraries and documents provided by kaixin.com assistant for developers, you can use my resources to complete some plug-ins you like.
Here I will issue some invitation codes for my Forum:
Http://www.dirain.cn/bbs/register.php? Invitecode = a1de3ea79804fmtc
Http://www.dirain.cn/bbs/register.php? Invitecode = 2155a8f2edw4wizi
Http://www.dirain.cn/bbs/register.php? Invitecode = 7fb1fc6037obfzb2
Http://www.dirain.cn/bbs/register.php? Invitecode = 882e091b361jjrww
Http://www.dirain.cn/bbs/register.php? Invitecode = ceec9fe58ahfcbfc
Http://www.dirain.cn/bbs/register.php? Invitecode = 5912a91454f553n8
Http://www.dirain.cn/bbs/register.php? Invitecode = b1c159faf5eemmae
Http://www.dirain.cn/bbs/register.php? Invitecode = d373d2f7fdq2qedq
Http://www.dirain.cn/bbs/register.php? Invitecode = c28a44b53bldulcz
Http://www.dirain.cn/bbs/register.php? Invitecode = 2f28e50ab1scsqsz
Http://www.dirain.cn/bbs/register.php? Invitecode = 631cfca158on4netease
Http://www.dirain.cn/bbs/register.php? Invitecode = b0%d11dwt4wr5
Http://www.dirain.cn/bbs/register.php? Invitecode = 32a16fd970dezydl
Http://www.dirain.cn/bbs/register.php? Invitecode = 6bc8a6e8fa8eunna
Http://www.dirain.cn/bbs/register.php? Invitecode = f9bb7c3f4b6axz56
Http://www.dirain.cn/bbs/register.php? Invitecode = 17626aff75t2r5ff
Http://www.dirain.cn/bbs/register.php? Invitecode = 02c5936fe5oo2wee
Http://www.dirain.cn/bbs/register.php? Invitecode = 8025cc2f771docss
Http://www.dirain.cn/bbs/register.php? Invitecode = 16ef48a0e7izf5gi
Http://www.dirain.cn/bbs/register.php? Invitecode = 2ef14fb78add39rr
Http://www.dirain.cn/bbs/register.php? Invitecode = 93d8a08bb21jm0oj
Http://www.dirain.cn/bbs/register.php? Invitecode = 8196a0c5fdidbj8w
Http://www.dirain.cn/bbs/register.php? Invitecode = 71dde6888de75qnz
Http://www.dirain.cn/bbs/register.php? Invitecode = cfabc7cdf13kvbfb
Http://www.dirain.cn/bbs/register.php? Invitecode = c2024281d9icwswp
Http://www.dirain.cn/bbs/register.php? Invitecode = 6ca5c38cda3ellyy
Http://www.dirain.cn/bbs/register.php? Invitecode = 97f72f420db250ys
Http://www.dirain.cn/bbs/register.php? Invitecode = f6b76eaa2ak62r5b
Http://www.dirain.cn/bbs/register.php? Invitecode = 9ca55a3b1cnofamo
Http://www.dirain.cn/bbs/register.php? Invitecode = fe4ac3f20cf6qkl9
Http://www.dirain.cn/bbs/register.php? Invitecode = 519648448dsokcc0.
Http://www.dirain.cn/bbs/register.php? Invitecode = 890a191c3715p44f
Http://www.dirain.cn/bbs/register.php? Invitecode = 8bb676ec3dttrf0r
Http://www.dirain.cn/bbs/register.php? Invitecode = e4c23c52e91lsy2m
Http://www.dirain.cn/bbs/register.php? Invitecode = 7da256482bi5863i
Http://www.dirain.cn/bbs/register.php? Invitecode = 102129f8654y98ym
Http://www.dirain.cn/bbs/register.php? Invitecode = 5bedomaind0871_pkwh