Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions vvzwvv/0004/0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import urllib
import re

def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html

def getImg(html):
# src="http://imgsrc.baidu.com/forum/w%3D580%3Bcp%3Dtieba%2C10%2C302%3Bap%3D%C9%BC%B1%BE%D3%D0%C3%C0%B0%C9%2C90%2C310/sign=8800a2e3b3119313c743ffb855036fa7/1e29460fd9f9d72abb1a7c3cd52a2834349bbb7e.jpg" bdwater=
reg = r'src="(.+?\.jpg)" bdwater='
img_re = re.compile(reg)
img_list = re.findall(img_re, html)
return img_list

def saveImg(img_list):
x = 0
for img_url in img_list:
urllib.urlretrieve(img_url, '%s.jpg' % x)
x += 1


if __name__ == "__main__":
html = getHtml("http://tieba.baidu.com/p/2166231880")
saveImg(getImg(html))
42 changes: 42 additions & 0 deletions vvzwvv/0010/0010.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import string
import random
from PIL import Image, ImageDraw, ImageFont, ImageFilter

def create_image(image_size = (300, 100),
background_color = (255, 255, 255),
font_type = "arialbd.ttf",
font_size = 50,
text_num = 4,
point_chance = 50):

im = Image.new("RGB", image_size, background_color)
draw = ImageDraw.Draw(im)
image_width, image_height = image_size

def create_text():
text_font = ImageFont.truetype(font_type, font_size)
font_width, font_height = text_font.getsize("A")
for i in range(text_num):
text = random.choice(string.ascii_uppercase)
text_loc = ((image_width - font_width) / text_num * (i + 0.5), (image_height - font_height) / 2.3)
draw.text(text_loc, text, font = text_font, fill = (random.randint(0, 255) / 2, random.randint(0, 255) / 2, random.randint(0, 255) / 2))

def create_points():
for w in range(image_width):
for h in range(image_height):
tmp = random.randint(0, 100)
if tmp > point_chance:
draw.point((w, h), fill = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)))

create_text()
create_points()
im = im.filter(ImageFilter.BLUR)

return im

if __name__ == "__main__":
im = create_image()
im.show()
Binary file added vvzwvv/0010/arialbd.ttf
Binary file not shown.
22 changes: 22 additions & 0 deletions vvzwvv/0011/0011.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from cmd import Cmd

class CmdCheck(Cmd):

def __init__(self):
Cmd.__init__(self)
self.intro = "-------- Word Sensor (Input \"exit\" for termination) --------"
self.prompt = "> "
self.sensitive = map(lambda word: word.strip("\n"), open("filtered_words.txt").readlines())

def default(self, line):
if any([word in line for word in self.sensitive]):
print "Freedom"
else:
print "Human Rights"

def do_exit(self, line):
exit()

if __name__ == "__main__":
cmd = CmdCheck()
cmd.cmdloop()
11 changes: 11 additions & 0 deletions vvzwvv/0011/filtered_words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
北京
程序员
公务员
领导
牛比
牛逼
你娘
你妈
love
sex
jiangge
22 changes: 22 additions & 0 deletions vvzwvv/0012/0012.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from cmd import Cmd

class CmdCheck(Cmd):

def __init__(self):
Cmd.__init__(self)
self.intro = "-------- Word Sensor (Input \"exit\" for termination) --------"
self.prompt = "> "
self.sensitive = map(lambda word: word.strip("\n"), open("filtered_words.txt").readlines())

def default(self, line):
for word in self.sensitive:
if word in line:
line = line.replace(word, ''.join("*" for i in range(len(word))))
print line

def do_exit(self, line):
exit()

if __name__ == "__main__":
cmd = CmdCheck()
cmd.cmdloop()
11 changes: 11 additions & 0 deletions vvzwvv/0012/filtered_words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
北京
程序员
公务员
领导
牛比
牛逼
你娘
你妈
love
sex
jiangge