Python Challenge [9]

Since I’m less a fan of images than of working with content directly from a site, I added functionality to this challenge to grab the useful text directly.

I don’t seem to be much a fan of the Image library. As such, it took me longer than it should have to wrap my head around this one. It turns out that the a solution, using the ImageDraw function, makes me feel like an idiot. Draw.polygon is a pretty simple and fundamental way to build graphics and, after the fact, I can see several potential uses ranging from mapping to dynamic drawings.

Just for good measure, we might as well pull the list from the site using urllib, some regex and eval to make it a tuple.

from PIL import Image, ImageDraw
import urllib, re, os

url = ""

rawhtml = urllib.urlopen(url).read().replace('\n','')
raw ='(([0-9]+),)+[0-9]+',rawhtml)
first_list = eval(

#or in one line
first = eval('(([0-9]+),)+[0-9]+',urllib.urlopen(url).read().replace('\n','')).group(0))

second = eval('(?<=second:)(([0-9]+),)+[0-9]+',urllib.urlopen(url).read().replace('\n','')).group(0))

Ok, now that we have our tuples, on to the actual challenge.

img ='RGB', (500,500))
draw = ImageDraw.Draw(img)


Check the image and mind the horns; I got a great laugh out of an improper solution to the puzzle, once I had the resulting image. Nice Easter egg.