Agility Pack for ASP.NET | How to parse a web page. which accepts message parameters?

I want to analyze and execute a page with POST parameters. this is my script. I need to analyze some search results. but the search parameter is sent to the body of the message on this page.

To analyze the search result, I need to send the parameters to this page in POST. How can I do this with the flexibility package?

please help me.

+4
source share
3 answers

Yes, you can probably publish options using the HTML Agility Pack. See below code.

BrowserSession b = new BrowserSession(); b.Get("http://www.skyline-eng.com/"); b.FormElements["navigationTypeID"] = rblCategory.SelectedItem.Value; b.FormElements["navigationSeriesID"] = boxItem.Value; HtmlDocument docSkyLine = b.Post("http://www.skyline-eng.com/"); 

Here navigationTypeID and navigationSeriesID are message parameters. Use this and continue to analyze data using the great HTMLAgility Pack tool.

+2
source

I don’t think the HTML flexibility package is for this. This is not an HTTP flexibility package; it does not parse an HTTP request. It just parses the HTML output (Ie answers, not requests).

You can access the POST parameters obtained on the page using the Page.Request[<param>] dictionary in the code behind this page.

If this is not what you are trying to do, can you clarify a little?

0
source

Use WebClient to send a message by sending any search page options. In the nusing Html Agility pack, you can parse the returned html.

WebClient will have the html that was returned by the search result.

Something like that:

  HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://exposureroom.com"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; string formParameters = "name1=value1&name1=value2"; byte[] requestBuffer = Encoding.ASCII.GetBytes(formParameters); var requestStream = request.GetRequestStream(); requestStream.Write(requestBuffer, 0, requestBuffer.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string str = reader.ReadToEnd(); 

In your case, the string variables formparameters should contain the query parameters that the search page requires. Then these parameters will be sent to your search page in the form of the "POST" Http method. Of course, the url must also be changed to your url.

0
source

All Articles