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
3 changes: 2 additions & 1 deletion renzongxian/0000/0000.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def add_num_to_img(file_path):
font = ImageFont.truetype("arial.ttf", int(im.size[0]/5))
im_draw.text((int(im.size[0]-im.size[0]/10), 5), "4", (256, 0, 0), font=font)
del im_draw
im.save(file_path)
im.save('./result.png')

if __name__ == "__main__":
if len(sys.argv) <= 1:
Expand All @@ -32,3 +32,4 @@ def add_num_to_img(file_path):
except IOError:
print("Can't open image!")
pass

29 changes: 29 additions & 0 deletions renzongxian/0008/0008.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Source:https://github.com/Show-Me-the-Code/show-me-the-code
# Author:renzongxian
# Date:2014-12-20
# Python 3.4

"""

第 0008 题:一个HTML文件,找出里面的正文。

"""

import urllib.request
import re


def get_body(url):
html_content = urllib.request.urlopen(url).read()
r = re.compile('<p>(?:<.[^>]*>)?(.*?)(?:<.[^>]*>)?</p>')
result = r.findall(html_content.decode('GBK'))
return result


if __name__ == '__main__':
body = get_body('http://tech.163.com/14/1219/01/ADPT7MTE000915BF.html')
file_object = open('result.txt', 'w')
for l in body:
file_object.write(l + '\n')
file_object.close()

23 changes: 23 additions & 0 deletions renzongxian/0009/0009.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Source:https://github.com/Show-Me-the-Code/show-me-the-code
# Author:renzongxian
# Date:2014-12-19
# Python 3.4

"""

第 0009 题:一个HTML文件,找出里面的链接。

"""

import urllib.request
import re


def find_links(website):
html_content = urllib.request.urlopen(website).read()
r = re.compile('href="(.*?)"')
result = r.findall(html_content.decode('GBK'))
return result

if __name__ == '__main__':
print(find_links('http://www.taobao.com/'))