首页 > 编程语言 > 详细

011 Python 爬虫库安装简单使用

时间:2017-07-27 09:13:59      阅读:298      评论:0      收藏:0      [点我收藏+]

# 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     

 

011 Python 爬虫库安装简单使用

原文:http://www.cnblogs.com/sdk123/p/7242949.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!