How to save image from another website programmatically?
How to save image from another website programmatically开发者_高级运维? Using asp.net c# for example I wouldlike to create request on google to search something for example beer and from search result save images using asp.net web application
it is easy. Crawl page, find url of the image with regex or jQuery for example and pass it as string to method below:
private void GetImage(string url)
{
Stream imageStream = new WebClient().OpenRead(url);
Image img = Image.FromStream(imageStream);
img.Save(@"C:\MyImage.jpg");
}
Sounds like you're trying to build a "spider" in C#... there is an open source sample project on CodeProject here: http://www.codeproject.com/KB/aspnet/ZetaWebSpider.aspx which should help get you going.
精彩评论