标签:nbsp beautiful lib strong html_ 基础知识 爬虫 font enc
# Python 爬虫基础知识
● Python 爬虫基础知识
安装爬虫库
beautifulsoup4
pip install beautifulsoup4
lxml HTML 解析器
pip install html5lib
html5lib
pip install html5lib
● 使用库
设置 encoding=‘utf-8‘ 编码
1 # -*- coding: UTF-8 -*- 2 from bs4 import BeautifulSoup 3 import lxml 4 html_file = open(‘text.html‘,encoding=‘utf-8‘) 5 6 soup = BeautifulSoup(html_file, "lxml") 7 8 for item in soup.find_all(‘span‘): 9 print(item.attrs) 10 11 html_file.close() 12
标签:nbsp beautiful lib strong html_ 基础知识 爬虫 font enc
原文地址:http://www.cnblogs.com/sdk123/p/7242949.html