From: leopold.moz@pythonchallenge.com
Subject: what do you mean by "open the attachment?"
Mime-version: 1.0
Content-type: Multipart/mixed; boundary="===============1295515792=="
It is so much easier for you, youngsters.
Maybe my computer is out of order.
I have a real work to do and I must know what's inside!
--===============1295515792==
Content-type: audio/x-wav; name="indian.wav"
Content-transfer-encoding: base64
import base64
f = open("indian.wav.txt",'r')
data = base64.b64decode(f.read())
f.close()
f = open("indian.wav",'wb')
f.write(data)
f.close()
print data
<html>
<head>
<title>can you tell the difference?</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<br><br>
<center>
<font color="gold">
<img src="balloons.jpg" border="0"/>
<!-- it is more obvious that what you might think -->
</body>
</html>
from PIL import Image, ImageDraw
im = Image.open('balloons.jpg')
rgb_im = im.convert('RGBA')
tmp = tmp1 = tmp2 = ""
print(rgb_im.size)
for x in range(0,rgb_im.size[0]):
for y in range(0,rgb_im.size[1]):
#print(str(x)+"/"+str(y)+"|"+str(x+375)+"/"+str(y))
pixelRGB=rgb_im.getpixel((x,y))
R = pixelRGB[0]
G = pixelRGB[1]
B = pixelRGB[2]
brightness = sum([R,G,B])/3
pixelRGB = rgb_im.getpixel((x+375,y))
R = pixelRGB[0]
G = pixelRGB[1]
B = pixelRGB[2]
brightness1 = sum([R,G,B])/3
#print(str(brightness)+"|"+str(brightness1)+"|"+str(brightness-brightness1)+"|"+chr(brightness-brightness1))
#print(chr(brightness)+"|"+chr(brightness1)+"|"+chr(brightness-brightness1)+"|")
print("--------------------------")
tmp+=chr(brightness)
tmp1+=chr(brightness1)
#tmp2+=chr(brightness-brightness1)
print("---")
print(tmp)
print("---")
print(tmp1)
print("---")
print(tmp2)
print("---")
import gzip,difflib
with gzip.open('deltas.gz', 'rb') as f:
file_content = f.read()
data1 = []
data2 = []
for line in file_content.split("\n"):
# print line
# print line[:53]
# print line[56:]
# print str(len(line[:53]))+" / "+str(len(line[56:]))
data1.append(str(line[:53].strip()))
data2.append(str(line[56:].strip()))
comp = list(difflib.Differ().compare(data1,data2))
#print comp
img1 = open('18_1.png','wb')
img2 = open('18_2.png','wb')
img3 = open('18_3.png','wb')
for line in comp:
byte = [chr(int(b,16)) for b in line[2:].split()]
print byte
if line[:1]=='+':
for tmp in byte:
img1.write(tmp)
pass
elif line[:1]=='-':
for tmp in byte:
img2.write(tmp)
pass
else:
for tmp in byte:
img3.write(tmp)
pass
img1.close()
img2.close()
img3.close()
import re,urllib
#insert url *.html
def find_img_src(url):
html = urllib.urlopen(url).read().split()
for word in html:
url = "http://huge:file@www.pythonchallenge.com/pc/return/"+str(word)+".jpg"
print(url)
word = re.findall(r'\ssrc="([^"]+)"', urllib.urlopen(url).read())
word = ' '.join(word)
if word!="":
return "http://huge:file@www.pythonchallenge.com/pc/return/"+str(word)
#insert url *.jpg
def find_word(url):
url = url[:-3]
html = urllib.urlopen(url+"html").read().split()
for word in html:
url = "http://huge:file@www.pythonchallenge.com/pc/return/"+str(word)
print(url)
if not("404" in urllib.urlopen(url).read()):
return url[:-3]+"html"
print (end")
url = "http://huge:file@www.pythonchallenge.com/pc/return/romance.html"
while 1:
print(url)
url=find_img_src(url)
print(url)
url = find_word(url)
pass
print "------------------------------------"
cookie = {'info': 'the flowers are on their way'}
r = requests.get('http://www.pythonchallenge.com/pc/stuff/violin.php', cookies=cookie)
print r.text
실행하면결과가나온다
<html>
<head>
<title>it's me. what do you want?</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<br><br>
<center><font color="gold">
<img src="leopold.jpg" border="0"/>
<br><br>
oh well, don't you dare to forget the balloons.</font>
</body>
</html>
from PIL import Image, ImageDraw,ImageChops
import subprocess, os
im = Image.open('mozart.gif')
width, height = im.size
#print im.info
offset_in = '\xc3'
frame = 0
#for y in range(1):
for y in range(height):
crop_box = (0 , y, width, y+1) #new make 1 line image
row = im.crop(crop_box) #crop to image
#row.show() #can see croped 1 line image
#print repr(row.tobytes()) #print method change tostrig ==> tobyte
row_byte = row.tobytes(); #save byte
#for i in range(len(row_byte)): # 1 line image proceed
# character = row_byte[i] #read 1 byte
# if character == row_byte[i+1] and character == row_byte[i+2] and character == row_byte[i+3]:
# #if same 3 pixel print byte value
# print repr(character)
offset = row_byte.index(offset_in) - 1 #get index to start index
row = ImageChops.offset(row, -offset) #offset split
im.paste(row,crop_box) #using offset to image pink area replace
im.save('frame'+str(frame).zfill(3)+".png") #file name upcount format
frame+=1 #file name up count
#file save
#make animation gif file
#using window
os.chdir(os.path.realpath(os.path.dirname(__file__))) #change dir
os.system('del animation.gif') #if have gif file then del
os.system("ffmpeg -i frame%03d.png animation.gif") #make animation gif file
os.system('del frame*.png') #del file
#using linux
#print subprocess.check_output('convert -delay 1 -loop 0 frame*.png animated.gif'.split()) # make anmation gif file
#im.show() #show file
im.close() #close file
os.system('animation.gif') #open file
<html>
<head>
<title>whom?</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<br><center>
<!-- he ain't the youngest, he is the second -->
<img src="screen15.jpg"><br>
</body>
</html>
<!-- todo: buy flowers for tomorrow -->
from datetime import date
import datetime
import calendar
#january 26-day find year
for x in range(1006,1996,10):
my_date = datetime.date(x,01,26)
if calendar.day_name[my_date.weekday()]=="Monday":
print "find : "+str(x)
pass
from datetime import date
import datetime
import calendar
#january 26-day find year
for x in range(1006,1996,10):
#print my_date.weekday()
if (calendar.weekday(x,1,26)==0 and calendar.isleap(x)):
print "find : "+str(x)
pass
<html>
<title>uzi</title>
<link rel="stylesheet" type="text/css" href="../style.css">
<body>
<center>
<br>
<font color="gold" size="+1">
and its name is <b>uzi</b>. you'll hear from him later.
<br><br><img src="uzi.jpg" width="640" height="480"/>
</body>
</html>