使用urllib获取一个静态页面内所有a标签的href标签

    1. import re, urllib.request, urllib.parse, urllib.error
    2. page = input('Enter - ')
    3. fhand = urllib.request.urlopen(page)
    4. for line in fhand:
    5. str = line.decode().strip()
    6. hrefs = re.findall('href="([^\"]*)"', str)
    7. for href in hrefs:
    8. print(href)

    urllib - 图1