python应用之爬虫实战2 请求库与解析库

知识内容:

1.requests库

2.selenium库

3.BeautifulSoup4库

一、requests库

1.安装及简单使用

(1)安装

1 pip3 install requests

(2)简单使用

1 import requests
2 
3 r = requests.get("http://www.baidu.com")        # 发起get请求
4 print(r.status_code)      # 打印状态码  
5 r.encoding = "utf-8"      # 指定编码
6 print(r.text)                  # 输出文本内容

2.基于GET请求

requests.get(url, params=None, **kwargs)

3.基于POST请求

4.响应Response

猜你喜欢

转载自www.cnblogs.com/wyb666/p/9058301.html