代码
# -*- coding: utf-8 -*-
# Author : zbz
import requests
from lxml import etree
url = "https://cn.bing.com/"
html = requests.get(url).text
tree = etree.HTML(html)
div = tree.xpath('//div[@id="est_en"]')
print(div)
for d in div:
d.getparent().remove(d)
# 已经删除了,所以div此时是[]
div = tree.xpath('//div[@id="est_en"]')
print(div)