HTML Source From URL
-
code for get HTML Source from input URL using System.Web.Caching; using System.Net; using System.IO; string URL = TextBox1.Text;//INPUT URL if (URL.Substring(0, 7) != "http://")//CHECK URL CONTAIN http:// { URL = "http://"+TextBox1.Text; } string ConvertURL =(string)Cache.Get(URL); if (ConvertURL == null) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(URL)); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader srdr = new StreamReader(res.GetResponseStream()); ConvertURL = srdr.ReadToEnd(); } Response.Write(ConvertURL);
-
code for get HTML Source from input URL using System.Web.Caching; using System.Net; using System.IO; string URL = TextBox1.Text;//INPUT URL if (URL.Substring(0, 7) != "http://")//CHECK URL CONTAIN http:// { URL = "http://"+TextBox1.Text; } string ConvertURL =(string)Cache.Get(URL); if (ConvertURL == null) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(URL)); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); StreamReader srdr = new StreamReader(res.GetResponseStream()); ConvertURL = srdr.ReadToEnd(); } Response.Write(ConvertURL);
makhaai wrote:
URL = "http://"+TextBox1.Text;
Why reading it from the text box again? Just do:
URL = "http://" + URL;
makhaai wrote:
string ConvertURL =(string)Cache.Get(URL);
Why do you look in the cache for the source? Do you have any code elsewhere that stores anything in the cache? You forgot to dispose the HttpWebResponse and the StreamReader.
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
-
makhaai wrote:
URL = "http://"+TextBox1.Text;
Why reading it from the text box again? Just do:
URL = "http://" + URL;
makhaai wrote:
string ConvertURL =(string)Cache.Get(URL);
Why do you look in the cache for the source? Do you have any code elsewhere that stores anything in the cache? You forgot to dispose the HttpWebResponse and the StreamReader.
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
He was not asking a question, it seems like he is advertising this[^]
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
-
He was not asking a question, it seems like he is advertising this[^]
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions
N a v a n e e t h wrote:
He was not asking a question
Yeah, I didn't see any question, but he got an answer anyway. :)
N a v a n e e t h wrote:
it seems like he is advertising this[^]
Seems you can take any crappy code and make a blog out of it... ;)
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams