none
How can i download images from a website? RRS feed

All replies

  • Hi Iceweasel,

    take a look at the WebRequest class (http://msdn.microsoft.com/en-us/library/system.net.webrequest(v=vs.80).aspx).

    There is also a example to request data by using http protocol.

     

    Regards

     

    Joerg

    Wednesday, December 29, 2010 7:03 PM
  • what imagem do you wnat to downlaod?

    if you wnat click on it and donwload.

    I think you are advertising, here the website,,,, that is bad man...

     


    Just Be Humble Malange!
    Wednesday, December 29, 2010 7:03 PM
  • Getting all the urls is the hard part.  You planning on supporting javascript?  Think about it -- this is a hard problem.  I suggest using an add-on for your browser that rakes all the images.  Something like https://addons.mozilla.org/en-US/firefox/addon/3404/

     

    Wednesday, December 29, 2010 7:05 PM
  • I want to write code in C sharp that will download images from a website.
    Wednesday, December 29, 2010 7:06 PM
  • download images from a web page using C# is not supported. You need an HTML parser and probably a javascript engine. Neither of these come with the language.

    If you are working on the PC or Mobile editions of Windows you could probably use the built-in IE as the HTML parser and script engine. If you are programming for linux/Windows Phone 7 then you probably want to visit the developmenet forum for the OS instead.



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Wednesday, December 29, 2010 7:23 PM
  • Maybe you can try to
    1. WebRequest to Stream
    2. Stream to XmlDocument
    3. Select Image Tags
    4. WebRequest to Images.

    This will only work if the HTML document is well formed.
    Else you must parse (steps 2&3) the document.

    Wednesday, December 29, 2010 7:36 PM
  • What are HTML parser and javascript engine?
    Wednesday, December 29, 2010 7:38 PM
  • This will only work if the HTML document is well formed.

    Nit picky (sorry):  This will only work if the document is XHTML.  (i.e.: well formed XML)  (and I assume that's what you intended.)

    well formed HTML != XML

     

    Wednesday, December 29, 2010 8:11 PM
  • When you get the document at a url such as http://www.digitalcamera-hq.com/ you have to fetch it via HTTP.  You can use an HttpWebRequest to do this.  (The example on msdn is bad because it doesn't treat the encoding properly. So, honestly, you're better off leaving this kind of work to a fully functional web-browser.)

    That hypertext document might (if you're lucky) be HTML or XHTML or some kind of SGML to describe a DOM (Document Object Model).  Once the DOM is built, there may be script to run as well, such as javascript.  This may further modify the DOM.  Once the DOM settles down, you can look around for img tags and find the url that specifies the resource.  Then you will have to perform another HTTP get to fetch the resource.  The resource will be an image file of some kind like jpg or png or gif.  You can simply save the img stream to a file.  You will, of course, have to divine some suitable local filename. (Repeat for each unique url.)

    Other images on websites may be HTML5 canvases or other non HTTP resources, these you'll have to get a different way.

    You could always write your own extension for a browser like Chrome and let the browser do the annoying part of the work.

    Wednesday, December 29, 2010 8:23 PM
  • Hi Iceweasel,

    According to your description of the problem, you'll need to post it in the dedicated ASP.Net Forum http://forums.asp.net for more efficient responses, where you can contact ASP.NET experts.

    Thank you for your understanding and support.

     

    Best Regards,

    Mio


    Mio Miao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 6, 2011 5:49 AM