Question related to webpage capture and Database???http://forums.asp.net/t/1693164.aspx/1?Question+related+to+webpage+capture+and+Database+Fri, 24 Jun 2011 09:45:11 -040016931644474181http://forums.asp.net/p/1693164/4474181.aspx/1?Question+related+to+webpage+capture+and+Database+Question related to webpage capture and Database??? <p>Hi,</p> <p>I want to store the whole data of a webpage in database. Can anyone tell me how i can do that?</p> <p>Whole data means whole page data.</p> <p>Like in google, i want to store all the data of that page.</p> <p>Please Help..</p> 2011-06-23T06:53:59-04:004474195http://forums.asp.net/p/1693164/4474195.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>nikunj25</h4> <p></p> <p>Hi,</p> <p>I want to store the whole data of a webpage in database. Can anyone tell me how i can do that?</p> <p>Whole data means whole page including all scripts, static data and images.</p> <p>Please Help..</p> <p></p> </blockquote> <br> <br> What is it that you are trying to achieve? From what I can read you want to create a template and that all your pages call apon that for their scripts, etc. This is actually easily achieved with WebMatrix and Razor syntax.<br> <br> This webpage will guide you through the process of creating a template - without having the need to call about a database continually for your scripts, etc. <br> <br> <a href="http://www.asp.net/webmatrix/tutorials/3-creating-a-consistent-look">http://www.asp.net/webmatrix/tutorials/3-creating-a-consistent-look</a><br> <br> Does this assist you? If not, please elaborate or provide an example and we/I will try to help :) <p></p> 2011-06-23T07:04:10-04:004474203http://forums.asp.net/p/1693164/4474203.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p></p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>a-rad</h4> <p></p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>nikunj25</h4> <p></p> <p>Hi,</p> <p>I want to store the whole data of a webpage in database. Can anyone tell me how i can do that?</p> <p>Whole data means whole page including all scripts, static data and images.</p> <p>Please Help..</p> <p></p> </blockquote> <br> <br> What is it that you are trying to achieve? From what I can read you want to create a template and that all your pages call apon that for their scripts, etc. This is actually easily achieved with WebMatrix and Razor syntax.<br> <br> This webpage will guide you through the process of creating a template - without having the need to call about a database continually for your scripts, etc. <br> <br> <a href="http://www.asp.net/webmatrix/tutorials/3-creating-a-consistent-look">http://www.asp.net/webmatrix/tutorials/3-creating-a-consistent-look</a><br> <br> Does this assist you? If not, please elaborate or provide an example and we/I will try to help :) <p></p> <p></p> </blockquote> <p></p> <p></p> <p>No, take google for an instance, i want to store all data present on google page in my database...</p> <p>How can i do that?</p> 2011-06-23T07:07:06-04:004474204http://forums.asp.net/p/1693164/4474204.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p>Hey,</p> <p>I think less possiblity to do that. but you can do one, &nbsp;simple convert whole page to PDF or you can download whole site.&nbsp;</p> <p>Try this links,&nbsp;<a href="http://www.httrack.com/">http://www.httrack.com/</a>&nbsp;or&nbsp;<a href="http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html">http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html</a>&nbsp;</p> <p>I hope this helps U</p> <p>Cheers !</p> <p><a href="http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html"></a></p> <p><a href="http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html"></a></p> <p><a href="http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html"></a></p> 2011-06-23T07:07:13-04:004474213http://forums.asp.net/p/1693164/4474213.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>ayyappan.CNN</h4> <p></p> <p>Hey,</p> <p>I think less possiblity to do that. but you can do one, &nbsp;simple convert whole page to PDF or you can download whole site.&nbsp;</p> <p>Try this links,&nbsp;<a href="http://www.httrack.com/">http://www.httrack.com/</a>&nbsp;or&nbsp;<a href="http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html">http://forum.esoft.in/applications/5489-metaproducts-offline-explorer-enterprise-5-0-2752-a.html</a>&nbsp;</p> <p>I hope this helps U</p> <p>Cheers !</p> <p></p> <p></p> <p></p> <p></p> </blockquote> <p></p> <p></p> <p>I want to write a code which will do that automatically..</p> 2011-06-23T07:10:43-04:004475887http://forums.asp.net/p/1693164/4475887.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p>Put this in a file called Helpers.cshtml in App_Code:</p> <pre class="prettyprint">@functions { public static string GetHtmlPage(string url){ WebRequest request = HttpWebRequest.Create(url); WebResponse response = request.GetResponse(); using (StreamReader sr = new StreamReader(response.GetResponseStream())){ return sr.ReadToEnd(); } } }</pre> <p>Then in your page, you can do this:</p> <pre class="prettyprint">var db = Database.Open("MyDb)"; var sql = "INSERT INTO table (myField) VALUES (@0); var page = Helpers.GetHtmlPage("http://www.google.com"); db.Execute(sql, page);</pre> <p></p> <p></p> 2011-06-24T04:49:49-04:004475968http://forums.asp.net/p/1693164/4475968.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Mikesdotnetting</h4> <p></p> <p>Put this in a file called Helpers.cshtml in App_Code:</p> <pre class="prettyprint">@functions { public static string GetHtmlPage(string url){ WebRequest request = HttpWebRequest.Create(url); WebResponse response = request.GetResponse(); using (StreamReader sr = new StreamReader(response.GetResponseStream())){ return sr.ReadToEnd(); } } }</pre> <p>Then in your page, you can do this:</p> <pre class="prettyprint">var db = Database.Open("MyDb)"; var sql = "INSERT INTO table (myField) VALUES (@0); var page = Helpers.GetHtmlPage("http://www.google.com"); db.Execute(sql, page);</pre> <p></p> <p></p> <p></p> </blockquote> <p></p> <p></p> <p>Thank You Mike.</p> <p>But in my table, i has a colume &quot;webpageStore&quot;. It is in varchar with max limit but when i am running Your code it is giving error.</p> <h2><i><i>0 : String truncation: max=4000, len=28951</i></i></h2> <p><i><i>length is greater than my row size.</i></i></p> <p>Ho can now remove this problem?</p> <p>Mike after fetching page can't we divide it in parts, so that it can be store in database?</p> <p>Please help...<i><i><br> </i></i></p> 2011-06-24T06:06:01-04:004475986http://forums.asp.net/p/1693164/4475986.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p>Use the nText data type.</p> <p></p> 2011-06-24T06:19:18-04:004476019http://forums.asp.net/p/1693164/4476019.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Mikesdotnetting</h4> <p></p> <p>Use the nText data type.</p> <p></p> <p></p> </blockquote> <p></p> <p></p> <p>Mike thanks for all help. Mike can you tell me a way like now everything in the page is storing but if i only wants page data not html tags, javascripts.</p> <p>Then it is posible to do that?</p> <p></p> 2011-06-24T06:32:01-04:004476381http://forums.asp.net/p/1693164/4476381.aspx/1?Re+Question+related+to+webpage+capture+and+Database+Re: Question related to webpage capture and Database??? <pre class="prettyprint">@using System.Text.RegularExpressions; @{ var page = Helpers.GetHtmlPage(&quot;http://www.google.com&quot;); page = Regex.Replace(page, @&quot;&lt;script.*?&lt;/script&gt;&quot;, string.Empty, RegexOptions.Singleline); page = Regex.Replace(page, @&quot;&lt;style.*?&lt;/style&gt;&quot;, string.Empty,RegexOptions.Singleline); page = Regex.Replace(page, @&quot;&lt;(.|\n)*?&gt;&quot;, string.Empty); var db = Database.Open(&quot;MyDb)&quot;; var sql = &quot;INSERT INTO table (myField) VALUES (@0); db.Execute(sql, cleaned); }</pre> 2011-06-24T09:45:11-04:00