Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7956627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:03:04+00:00 2026-06-04T04:03:04+00:00

This is the function im using and I want to save the images in

  • 0

This is the function im using and I want to save the images in the links i got from the website on my hard disk.

public void GetAllImages()
{

  // Bing Image Result for Cat, First Page
  string url = "http://www.bing.com/images/search?q=cat&go=&form=QB&qs=n";


  // For speed of dev, I use a WebClient
   WebClient client = new WebClient();
   string html = client.DownloadString(url);

   // Load the Html into the agility pack
   HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
   doc.LoadHtml(html);

   // Now, using LINQ to get all Images
   /*List<HtmlNode> imageNodes = null;
   imageNodes = (from HtmlNode node in doc.DocumentNode.SelectNodes("//img")
                              where node.Name == "img"
                              && node.Attributes["class"] != null
                              && node.Attributes["class"].Value.StartsWith("sg_t")
                              select node).ToList();*/

   var imageLinks = doc.DocumentNode.Descendants("img")
        .Where(n => n.Attributes["class"].Value == "sg_t")
        .Select(n => HttpUtility.ParseQueryString(n.Attributes["src"].Value["amp;url"])
        .ToList();





   foreach (string node in imageLinks)
     {
      y++;
      //Console.WriteLine(node.Attributes["src"].Value);
      richTextBox1.Text += node + Environment.NewLine;
      Bitmap bmp = new Bitmap(node);
      bmp.Save(@"d:\test\" + y.ToString("D6") + ".jpg");

      }

 }

In the bottom in the foreach im using Bitmap but then im getting the error. why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:03:05+00:00Added an answer on June 4, 2026 at 4:03 am

    You’re going to have to download the images first. You can’t save images from URIs like that. Get the bytes for the image using WebClient and then create your image using that data.

    Something like this:

    private System.Drawing.Image GetImage(string URI)
        {
            WebClient webClient = new WebClient();
            byte[] data = webClient.DownloadData(URI);
            MemoryStream memoryStream = new MemoryStream(data);
            return System.Drawing.Image.FromStream(memoryStream);
        }
    

    Then, I would suggest using System.Drawing.Image.Save to save it out: http://msdn.microsoft.com/en-us/library/system.drawing.image.save.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function I'm using and I want to be sure that it
I'm using this function: preg_match_all('/((\d{9})\.html)/s', $content, $results); It works fine but i just want
I want to use this function: http://www.frankmacdonald.co.uk/php/post-to-wordpress-with-php.html Its used to post to Wordpress using
I'm using this function to extract files from .zip archive and store it on
I am new in programing. I want to save images from Google Images. I
I am getting H.264 images from an IP camera and want to save the
I am using this function to close existing form and open a new form.
I am using this function https://www.php.net/sys_getloadavg to get a hint about my server load.
Dear all i am using this function to get the GMT time, i am
so I'm deploying a shipping calculator using this function , and I'm getting this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.