不用框架如何写爬虫

from urllib import request
import re
def main():
    response = request.urlopen(url='http://www.baidu.com')
    html = response.read().decode('utf8')
    p = '<title>(.*)</title>'
    mo = re.search(p, html)
    if mo:
        print(mo.groups(0))
    else:
        print('没有找到...')
    # with open('index.html', 'wb') as f:
    #     f.write(html)

if __name__ == '__main__':
    main()