一、parsel庫的安裝
pip install parsel
二、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()是獲取全部的值
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()是獲取全部的值
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。