【发布时间】:2014-02-22 23:02:02
【问题描述】:
这是我的示例 html 代码。
使用 HtmlXpathSelector 我需要解析 html 文件。
def 解析(自我,响应): edxData = HtmlXpathSelector(响应)
- 首先我需要获取所有包含 edxData.xpath('//h2[@class= "title course-title"]')
- 在那个标签里面我需要检查一个标签值。
- 然后需要解析带有类名subtitle 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>
【问题讨论】: