pip install parsel
1 import parsel 2 3 4 sel = parsel.Selector(html) 5 xp = sel.xpath('//div[@class="item top"]/p/a/text()').get() 6 print(xp)
注意:get()是获取单个值,getall()是获取全部的值