简体   繁体   中英

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");
        }

听起来你正试图在C#中构建一个“蜘蛛”... CodeProject上有一个开源示例项目: http//www.codeproject.com/KB/aspnet/ZetaWebSpider.aspx这应该有助于你去。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM