标签:imp color font str request ext pytho targe div
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)
传送门
标签:imp color font str request ext pytho targe div
原文地址:https://www.cnblogs.com/chengfengchi/p/12222538.html