123456789101112131415161718192021222324252627282930313233343536 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- ' a test module '
- __author__ = 'Michael Liao'
- import sys
- from bs4 import BeautifulSoup # 网页解析html文档
- import re # 正则表达式
- import urllib.request
- import urllib.error # 指定url获取网页数据
- import sqlite3 # 数据存储
- def test():
- args = sys.argv
- if len(args) == 1:
- print('Hello, world!')
- elif len(args) == 2:
- print('Hello, %s!' % args[1])
- else:
- print('Too many arguments!')
- path = "http://wwww.baidu.com"
- askUrl(path)
- def askUrl(path):
- response = urllib.request.urlopen(path)
- print(response.read().decode("utf-8"))
- if __name__ == '__main__':
- test()
|