listing15-1.py 226 B

123456
  1. from urllib.request import urlopen
  2. import re
  3. p = re.compile('<a href="(/jobs/\\d+)/">(.*?)</a>')
  4. text = urlopen('http://python.org/jobs').read().decode()
  5. for url, name in p.findall(text):
  6. print('{} ({})'.format(name, url))