This is a class that download an image from neopet, can be useful if you want to understand how it's done. I use something similar in my Wrapper to download the haggle image. Code (Text): using System.Net.Sockets; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Net; using System.ComponentModel; using System.Data; using System.Threading; using System.Collections; namespace AutoBuyer { public class DownloadImage { private Bitmap bitmap; private string referer_; private CookieContainer cookieJar_ = null; public DownloadImage(CookieContainer cookieJar, string referer) { cookieJar_ = cookieJar; referer_ = referer; } public void Download(string urlImage) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlImage); request.CookieContainer = cookieJar_; request.Method = "GET"; request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"; request.Accept = "image/png,image/*;q=0.8,*/*;q=0.5,en;q=0.3"; request.Headers.Add(HttpRequestHeader.AcceptLanguage, "en-us,en;q=0.5"); request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate"); request.Headers.Add(HttpRequestHeader.AcceptCharset, "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); request.Headers.Add(HttpRequestHeader.KeepAlive, "300"); request.KeepAlive = true; request.Proxy = null; request.Referer = referer_; request.AllowAutoRedirect = false; Console.WriteLine("download : " +urlImage + " with "+ referer_ + "as referer.."); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); System.IO.Stream responseStream = response.GetResponseStream(); if (response.ContentEncoding.ToLower().Contains("gzip")) responseStream = new GZipStream(responseStream, CompressionMode.Decompress); else if (response.ContentEncoding.ToLower().Contains("deflate")) responseStream = new DeflateStream(responseStream, CompressionMode.Decompress); bitmap = new Bitmap(responseStream); } catch (Exception e) { Console.WriteLine(e.Message); } } public Bitmap GetImage() { return bitmap; } public void SaveImage(string filename, ImageFormat format) { if (bitmap != null) { bitmap.Save(filename, format); } } } } simple and fast.
Hum... I don't know. I guess people don't like C# that much or don't know about it. I find it clearer/easier than VB since it looks like java and C/C++. Oh also this isn't a script it a class ^^, scripts are not oriented objet.