-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Labels
Description
from parsel import Selector
html = "<h3>吉林大学社会科学学报<p>Jilin University Journal Social Sciences Edition</p></h3>"
sel = Selector(html)
print(sel.css("h3"))
print(sel.css("h3 > p::text").getall())
当我使用css选择器时 无法获取h3下的p标签,结果如下:
[<Selector xpath='descendant-or-self::h3' data='<h3>吉林大学社会科学学报</h3>'>]
[]
当我将p标签换成其他标签时可以正常获取:
from parsel import Selector
html = "<h3>吉林大学社会科学学报<em>Jilin University Journal Social Sciences Edition</em></h3>"
sel = Selector(html)
print(sel.css("h3"))
print(sel.css("h3 > em::text").getall())
结果:
[<Selector xpath='descendant-or-self::h3' data='<h3>吉林大学社会科学学报<em>Jilin University Jo...'>]
['Jilin University Journal Social Sciences Edition']