File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ����
2+ ����Ա
3+ ����Ա
4+ �쵼
5+ ţ��
6+ ţ��
7+ ����
8+ ����
9+ love
10+ sex
11+ jiangge
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 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 )
Original file line number Diff line number Diff line change 1+ ����
2+ ����Ա
3+ ����Ա
4+ �쵼
5+ ţ��
6+ ţ��
7+ ����
8+ ����
9+ love
10+ sex
11+ jiangge
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments