首页 > pyquery css删除含指定class属性的标签

pyquery css删除含指定class属性的标签

我在爬取网页的时候,有些内容要去掉,但是不知道怎么去掉,比如,

<html><body><div class="id">Yeah!</div><p>python rocks !</p></div></html>

我要删除其中<div class="id">Yeah!</div>,得到<html><body><p>python rocks !</p></div></html>,怎么做呢?只知道需要去除的class,pyquery没找到现成的函数。


没有用过pyquery,不过我搜到的文档上有个方法

h = '<html><body><div class="id">Yeah!</div><p>python rocks !</p></div></html>'
d = PyQuery(h)
d('.id').remove()

这是我找的的api文档不知道对你有没有用

【热门文章】
【热门文章】