0
這是我的示例html代碼。如何使用xpath解析嵌套的html標記
使用HtmlXpathSelector我需要解析html文件。
DEF解析(個體,響應): edxData = HtmlXpathSelector(響應)
- 第一我需要得到所有包含 edxData.xpath標記('// H2 [@class =「標題課程標題「]')
- 裏面的標籤我需要檢查一個標籤值。
- 然後需要使用類名稱字幕course-subtitle copy-detail解析div標籤。 如何可以解析這個值好心給一些建議
樣本HTML響應數據:
遍歷內標籤<html>
<body>
<h2 class="title course-title">
<a href="https://www.edx.org/course/mitx/mitx-14-73x-challenges-global-poverty-1350">The Challenges of Global Poverty
</a>
</h2>
<div class="subtitle course-subtitle copy-detail">A course for those who are interested in the challenge posed by massive and persistent world poverty.
</div>
</body>
</html>