• Blogs (9)
    • šŸ“± 236 - 992 - 3846

      šŸ“§ jxjwilliam@gmail.com

    • Version: ā€šŸš€ 1.1.0
  • vi: wget images from site

    Blogs20112011-11-30


    vi: wget images from site

    Sometimes when we visit a website, we are expressive by the images and want to download them. Manually download is bored, here is a quick way to download them in Linux platform.

    • First use FireFox’s ā€˜Web Developer’ to get ā€˜generated resource’.
      ā€˜View Source’->ā€˜View Generated Source’.
    • Save the source in a file of Linux/Cygwin enviroment., such as $HOME/images/src_file.
    • The next step we operate the src_file to get the images like following:
    //0. locate to images/ folder.
    $ cd images/
    
    //1. strip images from html source.
    $ grep -i '.png' src_file >img_file
    $ grep -i '.jpg' src_file >>img_file
    $ grep -i '.jpeg' src_file >>img_file
    $ grep -i '.gif' src_file >>img_file
    
    //2. extract href links.
    $ vi img_file
    :1,$s/.*http/http/g
    :1,$s/".*//g
    
    //3. use wget to download these images.
    $ for i in `cat img_file`; do wget $i; done;

    It is done within 1 minute, no matter how many and big the images are. The key is to use wget - which is a perfect tool for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols.