python xpath
import requests from lxml import etree # //ul[@id = "showImg"]/li/a/img/@src text = requests.get('your url').text # html = etree.HTML(text) # result = etree.tostring(html) # print(result.decode('UTF-8')) html = etree.HTML(text) # '//'表示获取当前节点子孙节点,'*'表示所有节点,'//*'表示获取当前节点下所有节点 result = html.xpath('//ul[@id = "showImg"]/li/a/img/@src') for i in result: print(i)
传送门