在爬取LeetCode题目时,需要获取题目说明的Markdown格式内容从而建立项目的README.md文件,因此需要将获取的题目说明的HTML文本转换为Markdown文本。
1. 爬虫获取题目说明的HTML内容:
打开https://leetcode-cn.com/problems/to-lower-case/description/,可以看见题目详情,如下图所示:
获取该部分的HTML代码(爬虫教程可参考我的另一篇爬虫入门博客https://blog.csdn.net/egg1996911/article/details/79461063):
<p>实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串。</p>
<p> </p>
<p><strong>示例 1:</strong></p>
<pre><strong>输入: </strong>"Hello"
<strong>输出: </strong>"hello"</pre>
<p><strong>示例 2:</strong></p>
<pre><strong>输入: </strong>"here"
<strong>输出: </strong>"here"</pre>
<p><strong>示例</strong><strong> 3:</strong></p>