现在的位置: 首页 > 综合 > 正文

python3采集网页

2014年08月13日 ⁄ 综合 ⁄ 共 545字 ⁄ 字号 评论关闭

呈现一段最简单的代码:


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:





抱歉!评论已关闭.