Click here to Skip to main content
15,924,507 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I need to develop a web application i.e. web scrapper which fetches data from external web site, but it should fetch images also.

I want to know if Web scrapper can fetch images from external web site?
If no, do i have to check for path and download manually?

And if anyone knows best web scrapper which are ready to use, free or buy?

Thanks
Meenxi
Posted

1 solution

Images are not different from any other document you get through HTTP. You need to parse your currently loaded HTML page, find references to images and download each one separately.

Downloading via HTTP is fairly simple. Use System.Net.WebRequest class, bit your run-time class will be defined by the Uri and will be System.Net.HttpWebRequest in case of HTTP:

C#
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Proxy = proxy; // typically null
webResponse = (HttpWebResponse)webRequest.GetResponse();
fs = new FileStream(fname, FileMode.Append, FileAccess.Write);
//here you read data from file stream


Don't forget your HTTP file can use different kinds of URL schema for images. It can be FTP, for example. The download using FTP is as simple as HTTP, only your run-time type will be System.Net.FtpWebRequest.

See form more information http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^] and derived classes.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900