public static WebClient wClient = new WebClient(); public static TextWriter textWriter; public static String readFromLink() { string url = "http://www.ncedc.org/cgi-bin/catalog-search2.pl"; HttpWebRequest webRequest = WebRequest.Create(url) as HttpWebRequest; webRequest.Method = "POST"; System.Net.WebClient client = new System.Net.WebClient(); byte[] data = client.DownloadData(url); string html = System.Text.Encoding.UTF8.GetString(data); return html; } public static bool WriteTextFile(String fileName, String t) { try { textWriter = new StreamWriter(fileName); } catch (Exception) { return false; Console.WriteLine("Data Save Unsuccessful: Could Not create File"); } try { textWriter.WriteLine(t); } catch (Exception) { return false; Console.WriteLine("Data Save UnSuccessful: Could Not Save Data"); } textWriter.Close(); return true; Console.WriteLine("Data Save Successful"); } static void Main(string[] args) { String saveFile = "E:/test.txt"; String reSultString = readFromLink(); WriteTextFile(saveFile, reSultString); Console.ReadKey(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)