提取HTML内容

2024-10-02 04:24:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经提取了下面的HTML内容从一个网址使用刮

<div id="data">
       <div style="position:absolute">
            <h4 class="course">Python</h4>
            <h4 class="count">45</h4>
       </div>
       <h1 style="position:absolute">Available</h1>
       <h2 style="position:absolute">Weekend</h1>
       <h1 style="position:absolute">Paid Version</h1>
</div>

以及使用xpath

headerResponse = response.xpath('//div[@id="data"]').extract()

我已经将它们加载到headerResponse变量中。现在我想获取值,因为它没有id或类如何提取它们?你知道吗


Tags: divid内容datastylehtmlpositionh1

热门问题