Huang Cong: C # simulate the form for submitting POST data on the website page (1)-WebClient

Source: Internet
Author: User

The C # form submission method mainly includes two types of WebClient and HttpWebRequest. Here we first introduce one

WebClient, Transfer doors: http://msdn.microsoft.com/zh-cn/library/system.net.webclient (v = VS.80). aspx

String postString = "arg1 = a & arg2 = B"; // This is the passed parameter. You can use a tool to capture packets for analysis or analyze it yourself, in the form, each name must be added to byte [] postData = Encoding. UTF8.GetBytes (postString); // encoding, especially for Chinese characters. You must first check the encoding method of the captured webpage: string url = "http: // localhost/register. php "; // address: WebClient webClient = new WebClient (); webClient. headers. add ("Content-Type", "application/x-www-form-urlencoded"); // header required for POST, if you change the GET method, you can remove this sentence byte [] responseData = webClient. uploadData (url, "POST", postData); // returns the response stream string srcString = Encoding. UTF8.GetString (responseData); // decoded

 

You should pay attention to your website. If your webpage needs to be registered and logged on, please add a verification code. Similar principles are used for automatic registration machines and Forum Water Filling Machines.

However, this is what I relied on when I selected the course. This is also the advantage of the computer system !!!

Related Article

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.