爬虫-urllib-urlopen

初学爬虫,整理一些相关知识,方便查询

1、urlopen

语法:

resp = request.urlopen(url)

#读取所有内容

resp.read()

#读取指定n个内容

resp.read(n)

#读取一行内容

resp.readline()

#所有内容以行的形式读取

resp.readlines()

#获取状态码

resp.getcode()

待续...

posted @ 2018-01-11 18:45  第七王爵  阅读(133)  评论(0编辑  收藏  举报