Web text method

Here's a method for getting the text of a webpage.

static string getWebText(string url) { WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string html = reader.ReadToEnd(); return html; } 

It doesn't take any parameters you can't send in the URL but it will work for a lot of simple stuff to just grab information and then process it.


using System; using System.IO; using System.Net; 

by alex_the_bolshevik via /r/csharp

Leave a Reply