Httpwebrequest object captures images on the webpage

Source: Internet
Author: User
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 ();

}

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.