c# - How do you retrieve a snapshot of a website in ASP.NET? -


Can someone tell me how to re-upload an image or thumbnail of a website through my ASP.NET application? Can i get I have seen this functionality in some sites like Alexa etc.

Try Free and Easy Use Service Just create your image tag like this:

  & lt; Img src = "http://SnapCasa.com/Get.aspx?code=[code]&size=[size]& Url = [url]" / & gt;  

sign-up is required, but it is free for 500,000 requests every month [code] is an API key that provides after sign-up. [Size] is one of the three sizes available [Url] is the website address for which you want to display thumbnails.

If you want to work with the image from your code, here are some helpful methods:

Fixed public byte [] GetBytesFromUrl (string URL) {byte [ ] B; HttpWebRequest myReq = (HttpWebRequest) WebRequest.Create (url); WebResponse myResp = myReq.GetResponse (); Stream stream = myResp.GetResponseStream (); // IT i; (Using binaryreader BR = new binaryreader (stream)) {// i = (stream.line); B = br.ReadBytes (500000); Br.Close (); } MyResp.Close (); Return b; } Fixed Public Zero WriteBytesToFile (string filename, byte [] content) {FileStream fs = New FileStream (Filename, FileMode.Create); BinaryWriter w = New BinaryWriter (fs); Try {w.Write (content); } Finally {fs.Close (); W.Close (); }}

Then, in your code, just use:

  // Get a byte array for the image image by imagebytes = GetBytesFromUrl ("http : // SnapCasa .com / Get.aspx code = [code] & amp; size = [size] & url = [url] "); // Save the file to blank WriteBytesToFile ("c: \ someImageFile.jpg", imageBytes);  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -