post data through httpWebRequest

前端 未结 5 1284
情话喂你
情话喂你 2020-12-08 22:42

I need to \"Post\" some data to an external website using HttpWebRequest object from my application(desktop) and get a response back into my application through

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 23:13

    It looks like you will have to get the page with a HttpWebRequest and parse the content of the corresponding HttpWebResponse to find out the names of text boxes. Then you submit the values to the page by using another HttpWebRequest.

    So basically, what you need to do is the following:

    1. Issue a HttpWebRequest with GET method to the URL where the page with text boxes is located
    2. Get the response stream of the HttpWebResponse
    3. Parse the page contained in the response stream and get the names of text boxes. You can use HTML Agility Pack for this purpose.
    4. Issue a HttpWebRequest with POST method, with content type set to "application/x-www-form-urlencoded" and key-value pairs as the content.

提交回复
热议问题