I want to access a webpage & store the contents of the webpage into a database this is the code I have tried for reading the contents of the webpage
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(); } but this code gives me an o/p as- This script should be referenced with a METHOD of POST. REQUEST_METHOD=GET
please tell me how to resolve this
File.WriteAllTextdoes. And lines of the first method don't even matter...