Python Image Grabber pig.py

pig.py
Pigpy the pig.py creative commons mascot!

Python Image Grabber pig.py

Python Image Grabber or pig.py is a very simple python command line tool to download all the images from a given uri.

Enjoy!

Download and Installation:

https://bitbucket.org/russellballestrini/pig/raw/tip/pig.py

Usage:

python pig.py Example: python pig.py http://www.foxhop.net

Open Source:

pig.py has been placed in the public domain and its sourcecode may be viewed or branched here here: https://bitbucket.org/russellballestrini/pig

Pigpy Gimp Project

pigpy.xcf

2 thoughts on “Python Image Grabber pig.py

  1. You’re a python ninja. Here’s my favorite line:

    filename = img_uri.split(‘/’)[-1]

    It intrigues me. With the perl background I’m familiar with the whole split routine…but the [-1]… -1 from what? It’s a nice magic :)

    1. In python when you string split() a list (sometimes referred to as array in other languages) is returned. From that list I’m asking for the last index.

      Example:

      # a string
      img_uri = “www.foxhop.net/attachments/pic1.jpg”

      # a list of strings
      img_uri_parts = img_uri.split(‘/’)

      print img_uri_parts
      # >>> [‘www.foxhop.net’, ‘attachments’, ‘pic1.jpg’]

      # I want the filename, last part of the uri
      # In this case img_uri[2]
      # This will not always be true.
      # I always need the last element of the list.

      print img_uri_parts[-1]
      # >>> ‘pic1.jpg’

      For more information take a look at this page:

      http://docs.python.org/tutorial/datastructures.html

Leave a Reply

Your email address will not be published. Required fields are marked *