小菜鸟开始爬虫之旅了!记录一下!
安装库
安装 requests 库
1  | python3 -m pip install requests  | 
安装 beautifulsoup4
1  | python3 -m pip install beautifulsoup4  | 
爬取网页
import库
1  | import requests  | 
指定 url 并提取网页内容
1  | url = "https://……"  | 
处理网页内容
初始化 beautifulsoup4
1  | Soup = BeautifulSoup(html_doc, 'lxml')  | 
寻找需要的部分
1  | #网页里包含多个相同class的内容  | 
下载指定链接文件
1  | target_file = requests.get(url)  | 
mp3
1  | target_file = requests.get(url,stream=True)  | 
其他处理
速度减慢
1  | import time  |