Skip to content

Commit 06fe152

Browse files
committed
Merge pull request Show-Me-the-Code#63 from Rudy1224/master
Completed 0011, 0012, 0013
2 parents 294ad65 + 6e49d96 commit 06fe152

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

Rudy1224/0011/filtered_words.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
����
2+
����Ա
3+
����Ա
4+
�쵼
5+
ţ��
6+
ţ��
7+
����
8+
����
9+
love
10+
sex
11+
jiangge

Rudy1224/0011/inspector.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
f = open('filtered_words.txt')
2+
data = f.read()
3+
4+
wordlist = data.split('\n')
5+
6+
def inspector(input_line):
7+
flag = False
8+
for word in wordlist:
9+
if input_line.find(word)>=0:
10+
flag = True
11+
break
12+
else:
13+
pass
14+
if flag == True:
15+
print 'Freedom'
16+
else:
17+
print 'Human Rights'
18+
19+
while True:
20+
input_line = raw_input('>')
21+
inspector(input_line)

Rudy1224/0012/filter.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
f = open('filtered_words.txt')
2+
data = f.read()
3+
4+
wordlist = data.split('\n')
5+
6+
def word_filter(input_line):
7+
for word in wordlist:
8+
if input_line.find(word) == -1:
9+
pass
10+
else:
11+
input_line = input_line.replace(word, '*' * (len(word)/2))
12+
print input_line
13+
14+
while True:
15+
input_line = raw_input('>')
16+
word_filter(input_line)

Rudy1224/0012/filtered_words.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
����
2+
����Ա
3+
����Ա
4+
�쵼
5+
ţ��
6+
ţ��
7+
����
8+
����
9+
love
10+
sex
11+
jiangge

Rudy1224/0013/0013.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import urllib
2+
import re
3+
4+
def get_html(url):
5+
page = urllib.urlopen(url)
6+
html = page.read()
7+
return html
8+
9+
def get_img(html):
10+
reg = r'src="(.*?\.jpg)" bdwater='
11+
imgre = re.compile(reg)
12+
imglist = re.findall(imgre, html)
13+
i = 0
14+
for imgurl in imglist:
15+
urllib.urlretrieve(imgurl, '%s.jpg'%i)
16+
i+=1
17+
html = get_html('http://tieba.baidu.com/p/2166231880')
18+
print get_img(html)

0 commit comments

Comments
 (0)