Capture images on the webpage using the httpwebrequest object of C #
It doesn't make much sense. Although C # captures online images and displays them in picturebox, it is of little use, but it can capture a large number of verification codes at a fixed address. The Code is as follows:
Usingsystem;
Usingsystem. Collections. Generic;
Usingsystem. componentmodel;
Usingsystem. Data;
Usingsystem. drawing;
Usingsystem. text;
Usingsystem. Windows. forms;
Usingsystem. Collections. Specialized;
Usingsystem. Threading;
Usingsystem. net;
Usingsystem. IO;
Namespacegetwebimage
{
Publicpartialclassform1: Form
{
Publicform1 ()
{
Initializecomponent ();
}
Publicvoidgetimages (stringurl)
{
Try
{
Httpwebrequestrequest = (httpwebrequest) webrequest. Create (URL );
Streamresponsestream = (httpwebresponse) request. getresponse (). getresponsestream ();
Imageoriginal = image. fromstream (responsestream );
Bitmap_bitmap = newbitmap (original );
This. picturebox1.image = map_bitmap;
}
Catch (system. effectione)
{
MessageBox. Show ("error", E. Message. tostring ());
}
}
Privatevoidpicturebox#click (objectsender, eventargse)
{
}
Publicvoidgetthefuckingimage ()
{
Stringimageurl = "http://img.daqi.com/upload/slidepic/publish/2009-11-19/010_33978371_.jpg ";
Getimages (imageurl );
Privatevoidbutton#click (objectsender, eventargse)
{
// Open a new thread to prevent the interface from being suspended.
Threadthreadgetimage = newthread (newthreadstart (getthefuckingimage ));
Threadgetimage. Start ();
}
}
}