예제 #1
0
# http://www.pythonchallenge.com/pc/def/oxygen.html

import libs.web as web
import urllib
import Image

url = 'http://www.pythonchallenge.com/pc/def/oxygen.html'
src = web.get_page_source(url)
print(src)

print('================================')
print('================================')

oxygen_file = '/tmp/oxygen.png'
png_url = 'http://www.pythonchallenge.com/pc/def/oxygen.png'
filename, msg = urllib.urlretrieve(png_url, oxygen_file)
print filename, msg

print('================================')

image = Image.open(oxygen_file)
print image.format, image.size, image.mode

print('================================')

y_begin = 0
while y_begin < image.size[1]:
    pix = image.getpixel((0, y_begin))
    if pix[0] == pix[1] == pix[2]:
        break
    y_begin += 1
예제 #2
0
# http://www.pythonchallenge.com/pc/def/peak.html

import libs.web as web
import pickle

url = 'http://www.pythonchallenge.com/pc/def/peak.html'
src = web.get_page_source(url)
print(src)

print('================================')
print('================================')

peakhell = web.get_page_source('http://www.pythonchallenge.com/pc/def/banner.p')
print peakhell

print('================================')

obj = pickle.loads(peakhell)
print type(obj)

print('================================')

print obj

print('================================')

# for x in obj:
#     print ''.join(char * n for char, n in x)

print '\n'.join(''.join(char * cnt for char, cnt in x) for x in obj)