There is a https URL.
For example https://www.virustotal.com/en/domain/top.list.ru/information/
I need to get it html sourc. Without uploading pictures, css and the like. Just html code.
I tried all the methods that are advised on the foreign glassflow flow, but they all return an empty string for https, for some reason. (None of the options was checked on http, but judging by the number of pluses on the answers - c http works fine.)
I tried to manually set the header like UserAgent. The result is the same - returns an empty string.
An example of what I tried:
public static string GetHtmlFromUrl(string url) { WebClient webClient = new WebClient(); return webClient.DownloadString(url); } and
public static string GetHtmlFromUrl(string url) { if (url.Length > 0) { Uri myUri = new Uri(url); // Create a 'HttpWebRequest' object for the specified url. HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri); // Set the user agent as if we were a web browser myHttpWebRequest.UserAgent = @"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0"; HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); var stream = myHttpWebResponse.GetResponseStream(); var reader = new StreamReader(stream); var html = reader.ReadToEnd(); // Release resources of response object. myHttpWebResponse.Close(); return html; } else { return "NO URL"; } }