python基础爬虫-----Request库的get方法

1.内容介绍:

r = requests.get(url)信息介绍:
get()方法的格式:
Requests的两个重要对象:

2.看案例代码:

import requests
r = requests.get("http://www.baidu.com")
#检查是否正确连接服务器,并获取相应的信息
print(r.status_code)

r.encoding = 'utf-8'
print(r.text)
Response对象的属性:

3.使用get方法获取网络资源有下面几个流程:

4.有效编码:(一般用户可读的编码方式----“uft-8”)

备注:r.encoding:如果header中不存在charset,则认为编码为‘ISO-8859-1’

r.apparent_encoding:
发布了98 篇原创文章 · 获赞 34 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_42133768/article/details/99050891