爬虫---解析

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.正则表达式

 

posted @ 2018-04-10 20:43  Gaoyongxian666  阅读(147)  评论(0编辑  收藏  举报