python网络爬虫与信息提取

r=request.get(url)
构造一个向服务器请求资源的Request对象
返回的对象用r表示
python网络爬虫与信息提取
requests.get(url,params=None,**kwargs)

python网络爬虫与信息提取
如果打开request.get方法来封装
get方法用这样的形式来封装的
python网络爬虫与信息提取
response对象包含了返回对象
python网络爬虫与信息提取
python网络爬虫与信息提取
r.status_code请求状态码
如果是200即返回成功

5个属性

python网络爬虫与信息提取
r.status_code
r.text HTTP响应内容的字符串形式,即,url对应的页面内容
r.encoding HTTP header中猜测出来的编码方式
r.aparent_encoding
r.content HTTP响应内容的二进制形式

python网络爬虫与信息提取

python网络爬虫与信息提取
python网络爬虫与信息提取
网络上的资源有他的编码,我们需要编码的概念
如果Http header有这样的字段,资源编码有要求,会反悔过来,iso-8859-1不可以访问中文

当我们用encoding不可以返回
python网络爬虫与信息提取