呈现一段最简单的代码:
import urllib.request with urllib.request.urlopen('http://www.python.org/') as f: print(f.read().decode('utf-8'))
剩下的可以看官网
http://docs.python.org/3.3/library/urllib.html?highlight=urllib#urllib
更详细地可以看:
http://docs.python.org/3.3/library/urllib.request.html#module-urllib.request
21.5. urllib —
URL handling modules
urllib is a package that collects several modules
for working with URLs:
- urllib.request for
opening and reading URLs - urllib.error containing
the exceptions raised by urllib.request - urllib.parse for
parsing URLs - urllib.robotparser for
parsing robots.txt files