首页 > 其他 > 详细

爬虫---解析

时间:2018-04-10 20:52:03      阅读:193      评论:0      收藏:0      [点我收藏+]

1.beautifulsoup

https://www.crummy.com/software/BeautifulSoup/bs4/doc.zh/

pip install beautifulsoup4

1.1 解析库

建议lxml

技术分享图片

1.2 解析

四个对象:

# 四种对象:Tag , NavigableString , BeautifulSoup , Comment .

 tag对象的:string。gettext()。content。

遍历tag对象

head_tag.descendants:子孙节点
title_tag.children:子节点

寻找tag对象

soup.find_all(re.compile("t")):
soup.find_all(["a", "b"])

2.xpath

3.pyquery

4.正则表达式

 

爬虫---解析

原文:https://www.cnblogs.com/BlueFire-py/p/8782693.html

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