I need to extract data from an URL which returns HTML data. I can do it using Postman I just need the correct syntax to do it in ASP.NET MVC C#.
https://www.dsebd.org/ajax/load-news.php
Headers
accept:text/html, */*; q=0.01
accept-language:en-US,en;q=0.9
content-type:application/x-www-form-urlencoded; charset=UTF-8
sec-fetch-dest:empty
sec-fetch-mode:cors
sec-fetch-site:same-origin
x-requested-with:XMLHttpRequest
And the method is Post .
Can anyone please share me the syntax in ASP.NET MVC C#?
Guys I wanted the correct format. I never asked for the rules of web scraping.
var httpWebRequest = (HttpWebRequest)WebRequest.Create(String.Format(url));
httpWebRequest.Accept = "text/html, */*; q=0.01";
httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
httpWebRequest.Headers.Add("accept-language", "en-US,en;q=0.9");
httpWebRequest.Headers.Add("sec-fetch-dest", "empty");
httpWebRequest.Headers.Add("sec-fetch-mode", "cors");
httpWebRequest.Headers.Add("sec-fetch-site", "same-origin");
httpWebRequest.Headers.Add("x-requested-with", "XMLHttpRequest");
httpWebRequest.Method = "POST";
This is all I asked. Thanks for your help though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.