C # script code automatically login Taobao get user information

Source: Internet
Author: User
Tags reset

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/

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.