Recently encountered a demand is how to let the program automatically login taobao, get the user name and other information. In fact, the use of SS (Spiderstudio) to achieve a very simple. A dozen lines of code can be very sophisticated:
1. Run SS (download address), write a script to open Taobao landing page:
Default.navigate ("https://login.taobao.com/member/login.jhtml");
Default.ready ();
2. Find the user name, password input box, input information, click the login button:
var user = Default.selectsinglenode ("#TPL_username_1");
User. Focus (); Analog Click user Name text box
. Attr ("Value", "noxxxxxxx"); Enter user name
default.wait (1);//wait one second
default.selectsinglenode ("#TPL_password_1"). Attr ("Value", "*******"); Locate the Password box and enter
the password default.wait (1);/wait a second
var btnlogin = Default.selectsinglenode ("#J_SubmitStatic");
Btnlogin.click (); Click on the login button
Notice that there are two occurrences of default.wait (1) in your code. This is to control the rhythm. Taobao on the robot to guard against strict, if we entered too fast, Taobao will append the requirements of input verification code. If we control the rhythm, Taobao will think that this is a normal login, so do not verify the code is able to achieve login!
3. Waiting for login complete, page jump:
Default.reset ();
Default.ready ();
4. Get the user name of the node and display it:
var name = Default.selectsinglenode ("Div.name>a");
MessageBox.Show (name. Text ());
5. Complete scripting code:
public void Run ()
{
default.navigate ("https://login.taobao.com/member/login.jhtml");
Default.ready ();
var user = Default.selectsinglenode ("#TPL_username_1");
User. Focus ();
User. Attr ("Value", "nxxxxxxx");
Default.wait (1);
Default.selectsinglenode ("#TPL_password_1"). Attr ("Value", "********");
Default.wait (1);
var btnlogin = Default.selectsinglenode ("#J_SubmitStatic");
Btnlogin.click ();
Default.reset ();
Default.ready ();
var name = Default.selectsinglenode ("Div.name>a");
MessageBox.Show (name. Text ());
}
6. Operation Effect:
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/csharp/