python爬虫基础与http协议

315 阅读1分钟

概要:http协议的基本学习,python爬虫的基本学习。

1.http的请求和响应,请求包括请求行,请求头等等一系列的东西,请求中一个比较重要的知识就是get和post,其中get的传送数据量大,并且安全性低,post则相反。😁

2.爬虫的一个简单代码爬取2019版倚天屠龙记的赵敏主演陈钰琪的百度百科网页内容。

import urllib.request

response = urllib.request.urlopen('https://baike.baidu.com/item/%E9%99%88%E9%92%B0%E7%90%AA/4859301?fr=aladdin')
print(response.read().decode('utf-8'))

代码效果图如下: