当前位置:首页 > 文章列表 > 文章 > python教程 > BeautifulSoup提取HTML生成新文档方法

BeautifulSoup提取HTML生成新文档方法

2025-10-25 09:18:29 0浏览 收藏

亲爱的编程学习爱好者,如果你点开了这篇文章,说明你对《用BeautifulSoup提取HTML并生成新文档》很感兴趣。本篇文章就来给大家详细解析一下,主要介绍一下,希望所有认真读完的童鞋们,都有实质性的提高。

使用BeautifulSoup选择性提取HTML元素并构建新HTML文档

本文详细介绍了如何利用Python的BeautifulSoup库,从现有HTML文件中高效地提取指定标签及其内容,并构建一个新的HTML文档。通过迭代预定义的标签筛选规则,结合BeautifulSoup的find方法和append功能,我们能够避免繁琐的字符串拼接,实现更简洁、更具可维护性的HTML元素筛选与重构。

挑战:传统字符串拼接的局限性

在处理HTML文档时,我们经常需要从一个现有页面中提取特定部分,并将其组合成一个新的HTML文件。一种直观但效率不高的方法是,使用BeautifulSoup解析原始HTML,然后手动提取每个目标元素的字符串表示,并通过字符串拼接的方式构建新页面的HTML内容。例如:

from bs4 import BeautifulSoup

with open('P:/Test.html', 'r') as f:
    contents = f.read()
    soup= BeautifulSoup(contents, 'html.parser')

NewHTML = "<html><body>"
NewHTML+="\n"+str(soup.find('title'))
NewHTML+="\n"+str(soup.find('p', attrs={'class': 'm-b-0'}))
NewHTML+="\n"+str(soup.find('div', attrs={'id' :'right-col'}))
NewHTML+= "</body></html>"

with open("output1.html", "w") as file:
    file.write(NewHTML)

这种方法虽然能够实现目标,但存在明显的局限性:

  1. 可维护性差:当需要提取的元素数量增多或结构变得复杂时,手动拼接字符串会变得异常繁琐且容易出错。
  2. 非BeautifulSoup惯用方式:BeautifulSoup提供了强大的API来操作HTML树结构,直接拼接字符串未能充分利用这些功能。
  3. 潜在的解析问题:手动拼接可能导致HTML结构不完整或格式不正确,尤其是在处理包含特殊字符或嵌套结构的元素时。

为了解决这些问题,我们可以采用BeautifulSoup提供的方法,以更优雅和健壮的方式构建新的HTML文档。

核心策略:BeautifulSoup的元素操作

BeautifulSoup允许我们像操作DOM一样操作HTML元素。其关键在于:

  1. 创建新的BeautifulSoup对象:将其作为新HTML文档的容器。
  2. 利用find()或find_all()定位元素:在原始HTML中找到需要提取的元素。
  3. 使用append()方法追加元素:将找到的元素(BeautifulSoup Tag对象)直接添加到新HTML文档的相应位置(如body标签内)。

这种方法避免了字符串层面的操作,直接在BeautifulSoup的解析树层面进行,确保了HTML结构的正确性和一致性。

实现步骤详解

下面将详细介绍如何通过BeautifulSoup的append方法,选择性地从一个HTML页面中提取特定标签并构建一个新的HTML文件。

1. 加载源HTML文档

首先,我们需要读取并解析包含源内容的HTML文件。

from bs4 import BeautifulSoup

# 假设原始HTML文件名为 'Test.html'
with open('Test.html', 'r', encoding='utf-8') as f:
    contents = f.read()
    soup = BeautifulSoup(contents, 'html.parser')

注意:为了避免编码问题,建议在打开文件时明确指定编码,例如encoding='utf-8'。

2. 初始化目标HTML结构

创建一个新的BeautifulSoup对象,作为我们即将构建的新HTML文档的骨架。通常,我们会从一个基本的结构开始。

new_html = BeautifulSoup("<html><body></body></html>", 'html.parser')

此时,new_html是一个空的HTML文档结构,其body标签是我们可以向其中追加元素的根节点。

3. 定义元素筛选规则

为了灵活地选择需要保留的元素,我们可以定义一个列表,其中包含要提取的标签名称或带有属性的标签信息。

  • 对于仅按标签名筛选的元素,可以直接使用字符串。
  • 对于需要按标签名和属性筛选的元素,可以使用字典,键为标签名,值为属性字典。
tags_to_keep = [
    'title',                               # 提取 <title> 标签
    {'p': {'class': 'm-b-0'}},             # 提取 class 为 'm-b-0' 的 <p> 标签
    {'div': {'id': 'right-col'}}           # 提取 id 为 'right-col' 的 <div> 标签
]

4. 迭代筛选并追加元素

遍历tags_to_keep列表。根据每个元素的类型(字符串或字典),使用soup.find()方法在原始soup对象中查找对应的元素,然后将其追加到new_html.body中。

for tag_rule in tags_to_keep:
    found_element = None
    if isinstance(tag_rule, str):
        # 如果是字符串,按标签名查找
        found_element = soup.find(tag_rule)
    elif isinstance(tag_rule, dict):
        # 如果是字典,提取标签名和属性进行查找
        tag_name = list(tag_rule.keys())[0]
        tag_attrs = tag_rule[tag_name]
        found_element = soup.find(tag_name, attrs=tag_attrs)

    # 检查是否找到元素,避免追加 None
    if found_element:
        new_html.body.append(found_element)

5. 保存新HTML文件

最后,将构建好的new_html对象转换为字符串,并写入到一个新的HTML文件中。

with open("output1.html", "w", encoding='utf-8') as file:
    file.write(str(new_html))

示例代码

将上述步骤整合到一起,完整的实现代码如下:

from bs4 import BeautifulSoup

# 1. 加载源HTML文档
with open('Test.html', 'r', encoding='utf-8') as f:
    contents = f.read()
    soup = BeautifulSoup(contents, 'html.parser')

# 2. 初始化目标HTML结构
new_html = BeautifulSoup("<html><body></body></html>", 'html.parser')

# 3. 定义元素筛选规则
tags_to_keep = [
    'title',                               # 提取 <title> 标签
    {'p': {'class': 'm-b-0'}},             # 提取 class 为 'm-b-0' 的 <p> 标签
    {'div': {'id': 'right-col'}}           # 提取 id 为 'right-col' 的 <div> 标签
]

# 4. 迭代筛选并追加元素
for tag_rule in tags_to_keep:
    found_element = None
    if isinstance(tag_rule, str):
        # 如果是字符串,按标签名查找
        found_element = soup.find(tag_rule)
    elif isinstance(tag_rule, dict):
        # 如果是字典,提取标签名和属性进行查找
        tag_name = list(tag_rule.keys())[0]
        tag_attrs = tag_rule[tag_name]
        found_element = soup.find(tag_name, attrs=tag_attrs)

    # 检查是否找到元素,避免追加 None
    if found_element:
        # Beautiful Soup的append方法会将元素及其所有子元素一并追加
        new_html.body.append(found_element)

# 5. 保存新HTML文件
with open("output1.html", "w", encoding='utf-8') as file:
    file.write(str(new_html))

print("新HTML文件 'output1.html' 已生成。")

源HTML示例

为了更好地理解上述代码的运行效果,假设Test.html文件内容如下:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>测试页面</title>
</head>
<body>
    <h1>这是一个标题</h1>
    <p class="m-b-0">这是一个带有特定类名的段落。</p>
    <div id="left-col">
        <p>左侧列内容。</p>
    </div>
    <div id="right-col">
        <p>右侧列内容。</p>
        <span>更多右侧内容。</span>
    </div>
    <p>这是另一个普通段落。</p>
</body>
</html>

生成结果预览

运行上述Python代码后,output1.html文件将包含以下内容:

<html>
 <body>
  <title>
   测试页面
  </title>
  <p class="m-b-0">
   这是一个带有特定类名的段落。
  </p>
  <div id="right-col">
   <p>
    右侧列内容。
   </p>
   <span>
    更多右侧内容。
   </span>
  </div>
 </body>
</html>

可以看到,原始页面中的、带有class="m-b-0"的<p>标签以及带有id="right-col"的<div>标签及其所有子元素都被成功提取并组合到了新的HTML文件中。</p><h3>注意事项与进阶考量</h3><ol><li><p><strong>处理未找到的元素</strong>:soup.find()在找不到匹配元素时会返回None。在追加之前进行if found_element:检查是良好的编程习惯,可以避免将None对象添加到HTML树中,从而导致潜在的错误或不完整的输出。</p></li><li><p><strong>选择多个匹配项 (find_all)</strong>:如果需要提取所有符合条件的元素,而不是第一个匹配项,应使用soup.find_all()方法。find_all()会返回一个BeautifulSoup Tag对象的列表,你需要遍历这个列表,并将每个找到的元素逐一追加到新HTML文档中。</p><pre># 示例:提取所有 <p> 标签 all_paragraphs = soup.find_all('p') for p_tag in all_paragraphs: new_html.body.append(p_tag)</pre></li><li><p><strong>构建复杂新结构</strong>:本教程示例将所有元素追加到body标签下。如果需要构建更复杂的HTML结构(例如,将某些元素放入head,另一些放入body的特定div中),你需要创建更多的BeautifulSoup Tag对象,并使用append()、insert()等方法将元素放置到精确的位置。</p></li><li><p><strong>编码问题</strong>:在读取和写入文件时,务必注意文件编码。通常推荐使用utf-8。</p></li><li><p><strong>性能考量</strong>:对于非常大的HTML文件和大量的提取操作,BeautifulSoup的解析和操作可能会消耗较多内存和时间。在极端情况下,可以考虑其他更底层的HTML解析库,但对于大多数网页抓取和处理任务,BeautifulSoup的性能是完全足够的。</p></li></ol><h3>总结</h3><p>通过利用BeautifulSoup的内部机制,我们可以以一种声明式和结构化的方式从现有HTML文档中提取并重构新的HTML内容。这种方法不仅代码更简洁、更易于理解和维护,而且能够确保生成的HTML结构是有效的。掌握find()、find_all()和append()等核心方法,将大大提高你在Python中处理HTML文档的效率和健壮性。</p><p>今天关于《BeautifulSoup提取HTML生成新文档方法》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!</p> </div> <div class="labsList"> </div> <div class="cateBox"> <div class="cateItem"> <a href="/article/358964.html" title="哔哩哔哩直播回放怎么查看" class="img_box"> <img src="/uploads/20251025/176135510968fc25650556c.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="哔哩哔哩直播回放怎么查看">哔哩哔哩直播回放怎么查看 </a> <dl> <dt class="lineOverflow"><a href="/article/358964.html" title="哔哩哔哩直播回放怎么查看" class="aBlack">上一篇<i></i></a></dt> <dd class="lineTwoOverflow">哔哩哔哩直播回放怎么查看</dd> </dl> </div> <div class="cateItem"> <a href="/article/358966.html" title="最长连续相同元素查找技巧" class="img_box"> <img src="/uploads/20251025/176135511168fc2567dfd95.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="最长连续相同元素查找技巧"> </a> <dl> <dt class="lineOverflow"><a href="/article/358966.html" class="aBlack" title="最长连续相同元素查找技巧">下一篇<i></i></a></dt> <dd class="lineTwoOverflow">最长连续相同元素查找技巧</dd> </dl> </div> </div> </div> </div> <div class="leftContBox pt0"> <div class="pdl20"> <div class="contTit"> <a href="/articlelist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit">最新文章</div> </div> </div> <ul class="newArticleList"> <li> <div class="contBox"> <a href="/article/405884.html" class="img_box" title="Python语言入门与基础解析"> <img src="/uploads/20251202/1764689258692f056a8ed85.png" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python语言入门与基础解析"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  1小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405884.html" class="aBlack" target="_blank" title="Python语言入门与基础解析">Python语言入门与基础解析</a> </dt> <dd class="cont2"> <span><i class="view"></i>296浏览</span> <span class="collectBtn user_collection" data-id="405884" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405860.html" class="img_box" title="PyMongo导入CSV:类型转换技巧详解"> <img src="/uploads/20251202/1764688178692f0132ee9fb.jpg" onerror="this.src='/assets/images/moren/morentu.png'" alt="PyMongo导入CSV:类型转换技巧详解"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  1小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405860.html" class="aBlack" target="_blank" title="PyMongo导入CSV:类型转换技巧详解">PyMongo导入CSV:类型转换技巧详解</a> </dt> <dd class="cont2"> <span><i class="view"></i>351浏览</span> <span class="collectBtn user_collection" data-id="405860" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405857.html" class="img_box" title="Python列表优势与实用技巧"> <img src="/uploads/20251202/1764687998692f007e82c9f.png" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python列表优势与实用技巧"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  1小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405857.html" class="aBlack" target="_blank" title="Python列表优势与实用技巧">Python列表优势与实用技巧</a> </dt> <dd class="cont2"> <span><i class="view"></i>157浏览</span> <span class="collectBtn user_collection" data-id="405857" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405839.html" class="img_box" title="Pandas修改首行数据技巧分享"> <img src="/uploads/20251202/1764687099692efcfbd2ff7.jpg" onerror="this.src='/assets/images/moren/morentu.png'" alt="Pandas修改首行数据技巧分享"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  1小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405839.html" class="aBlack" target="_blank" title="Pandas修改首行数据技巧分享">Pandas修改首行数据技巧分享</a> </dt> <dd class="cont2"> <span><i class="view"></i>485浏览</span> <span class="collectBtn user_collection" data-id="405839" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405712.html" class="img_box" title="Python列表创建技巧全解析"> <img src="/uploads/20251202/1764680976692ee5102e688.png" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python列表创建技巧全解析"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  3小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405712.html" class="aBlack" target="_blank" title="Python列表创建技巧全解析">Python列表创建技巧全解析</a> </dt> <dd class="cont2"> <span><i class="view"></i>283浏览</span> <span class="collectBtn user_collection" data-id="405712" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405686.html" class="img_box" title="Python计算文件实际占用空间技巧"> <img src="/uploads/20251202/1764679537692edf71a488d.jpg" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python计算文件实际占用空间技巧"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  3小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405686.html" class="aBlack" target="_blank" title="Python计算文件实际占用空间技巧">Python计算文件实际占用空间技巧</a> </dt> <dd class="cont2"> <span><i class="view"></i>349浏览</span> <span class="collectBtn user_collection" data-id="405686" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405643.html" class="img_box" title="Python网页连接数据库方法详解"> <img src="/uploads/20251202/1764677377692ed701abc20.png" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python网页连接数据库方法详解"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  4小时前  |   <a href="javascript:;" class="aLightGray" title="Python">Python</a> <a href="javascript:;" class="aLightGray" title="Web框架">Web框架</a> <a href="javascript:;" class="aLightGray" title="数据库连接">数据库连接</a> <a href="javascript:;" class="aLightGray" title="orm">orm</a> <a href="javascript:;" class="aLightGray" title="数据操作">数据操作</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/405643.html" class="aBlack" target="_blank" title="Python网页连接数据库方法详解">Python网页连接数据库方法详解</a> </dt> <dd class="cont2"> <span><i class="view"></i>291浏览</span> <span class="collectBtn user_collection" data-id="405643" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405607.html" class="img_box" title="OpenCV中OCR技术应用详解"> <img src="/uploads/20251202/1764675692692ed06c14b99.png" onerror="this.src='/assets/images/moren/morentu.png'" alt="OpenCV中OCR技术应用详解"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  4小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405607.html" class="aBlack" target="_blank" title="OpenCV中OCR技术应用详解">OpenCV中OCR技术应用详解</a> </dt> <dd class="cont2"> <span><i class="view"></i>204浏览</span> <span class="collectBtn user_collection" data-id="405607" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405532.html" class="img_box" title="Pandas读取Django表格:协议关键作用"> <img src="/uploads/20251202/1764672337692ec3516cf50.jpg" onerror="this.src='/assets/images/moren/morentu.png'" alt="Pandas读取Django表格:协议关键作用"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  5小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405532.html" class="aBlack" target="_blank" title="Pandas读取Django表格:协议关键作用">Pandas读取Django表格:协议关键作用</a> </dt> <dd class="cont2"> <span><i class="view"></i>401浏览</span> <span class="collectBtn user_collection" data-id="405532" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405524.html" class="img_box" title="Python调用API下载文件方法"> <img src="/uploads/20251202/1764671915692ec1ab86be3.png" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python调用API下载文件方法"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  5小时前  |   <a href="javascript:;" class="aLightGray" title="身份验证">身份验证</a> <a href="javascript:;" class="aLightGray" title="断点续传">断点续传</a> <a href="javascript:;" class="aLightGray" title="requests库">requests库</a> <a href="javascript:;" class="aLightGray" title="PythonAPI下载">PythonAPI下载</a> <a href="javascript:;" class="aLightGray" title="urllib库">urllib库</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/405524.html" class="aBlack" target="_blank" title="Python调用API下载文件方法">Python调用API下载文件方法</a> </dt> <dd class="cont2"> <span><i class="view"></i>227浏览</span> <span class="collectBtn user_collection" data-id="405524" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405521.html" class="img_box" title="Windows7安装RtMidi失败解决办法"> <img src="/uploads/20251202/1764671800692ec13867ebc.jpg" onerror="this.src='/assets/images/moren/morentu.png'" alt="Windows7安装RtMidi失败解决办法"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  5小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405521.html" class="aBlack" target="_blank" title="Windows7安装RtMidi失败解决办法">Windows7安装RtMidi失败解决办法</a> </dt> <dd class="cont2"> <span><i class="view"></i>400浏览</span> <span class="collectBtn user_collection" data-id="405521" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/405512.html" class="img_box" title="Python异步任务优化技巧分享"> <img src="/uploads/20251202/1764671438692ebfce050ec.jpg" onerror="this.src='/assets/images/moren/morentu.png'" alt="Python异步任务优化技巧分享"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/19_new_0_1.html" class="aLightGray" title="文章">文章</a> · <a href="/articlelist/86_new_0_1.html" class="aLightGray" title="python教程">python教程</a>   |  6小时前  |   </span> </dd> <dt class="lineOverflow"> <a href="/article/405512.html" class="aBlack" target="_blank" title="Python异步任务优化技巧分享">Python异步任务优化技巧分享</a> </dt> <dd class="cont2"> <span><i class="view"></i>327浏览</span> <span class="collectBtn user_collection" data-id="405512" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> </ul> </div> </div> <div class="mainRight"> <!-- 右侧广告位banner --> <div class="rightContBox" style="margin-top: 0px;"> <div class="rightTit"> <a href="/courselist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">课程推荐</div> </div> <ul class="lessonRecomRList"> <li> <a href="/course/9.html" class="img_box" target="_blank" title="前端进阶之JavaScript设计模式"> <img src="/uploads/20221222/52fd0f23a454c71029c2c72d206ed815.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="前端进阶之JavaScript设计模式"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/9.html" target="_blank" class="aBlack" title="前端进阶之JavaScript设计模式">前端进阶之JavaScript设计模式</a></dt> <dd class="cont1 lineTwoOverflow"> 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。 </dd> <dd class="cont2">543次学习</dd> </dl> </li> <li> <a href="/course/2.html" class="img_box" target="_blank" title="GO语言核心编程课程"> <img src="/uploads/20221221/634ad7404159bfefc6a54a564d437b5f.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="GO语言核心编程课程"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/2.html" target="_blank" class="aBlack" title="GO语言核心编程课程">GO语言核心编程课程</a></dt> <dd class="cont1 lineTwoOverflow"> 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。 </dd> <dd class="cont2">516次学习</dd> </dl> </li> <li> <a href="/course/74.html" class="img_box" target="_blank" title="简单聊聊mysql8与网络通信"> <img src="/uploads/20240103/bad35fe14edbd214bee16f88343ac57c.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="简单聊聊mysql8与网络通信"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/74.html" target="_blank" class="aBlack" title="简单聊聊mysql8与网络通信">简单聊聊mysql8与网络通信</a></dt> <dd class="cont1 lineTwoOverflow"> 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让 </dd> <dd class="cont2">500次学习</dd> </dl> </li> <li> <a href="/course/57.html" class="img_box" target="_blank" title="JavaScript正则表达式基础与实战"> <img src="/uploads/20221226/bbe4083bb3cb0dd135fb02c31c3785fb.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="JavaScript正则表达式基础与实战"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/57.html" target="_blank" class="aBlack" title="JavaScript正则表达式基础与实战">JavaScript正则表达式基础与实战</a></dt> <dd class="cont1 lineTwoOverflow"> 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。 </dd> <dd class="cont2">487次学习</dd> </dl> </li> <li> <a href="/course/28.html" class="img_box" target="_blank" title="从零制作响应式网站—Grid布局"> <img src="/uploads/20221223/ac110f88206daeab6c0cf38ebf5fe9ed.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="从零制作响应式网站—Grid布局"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/28.html" target="_blank" class="aBlack" title="从零制作响应式网站—Grid布局">从零制作响应式网站—Grid布局</a></dt> <dd class="cont1 lineTwoOverflow"> 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。 </dd> <dd class="cont2">485次学习</dd> </dl> </li> </ul> </div> <div class="rightContBox"> <div class="rightTit"> <a href="/ai.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">AI推荐</div> </div> <ul class="lessonRecomRList"> <li> <a href="/ai/13100.html" target="_blank" title="ChatExcel酷表:告别Excel难题,北大团队AI助手助您轻松处理数据" class="img_box"> <img src="/uploads/20251027/176155320368ff2b3345c06.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="ChatExcel酷表:告别Excel难题,北大团队AI助手助您轻松处理数据" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13100.html" class="aBlack" target="_blank" title="ChatExcel酷表">ChatExcel酷表</a></dt> <dd class="cont1 lineTwoOverflow"> ChatExcel酷表是由北京大学团队打造的Excel聊天机器人,用自然语言操控表格,简化数据处理,告别繁琐操作,提升工作效率!适用于学生、上班族及政府人员。 </dd> <dd class="cont2">3180次使用</dd> </dl> </li> <li> <a href="/ai/13099.html" target="_blank" title="Any绘本:开源免费AI绘本创作工具深度解析" class="img_box"> <img src="/uploads/20251023/176120760368f9e5333da5f.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="Any绘本:开源免费AI绘本创作工具深度解析" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13099.html" class="aBlack" target="_blank" title="Any绘本">Any绘本</a></dt> <dd class="cont1 lineTwoOverflow"> 探索Any绘本(anypicturebook.com/zh),一款开源免费的AI绘本创作工具,基于Google Gemini与Flux AI模型,让您轻松创作个性化绘本。适用于家庭、教育、创作等多种场景,零门槛,高自由度,技术透明,本地可控。 </dd> <dd class="cont2">3391次使用</dd> </dl> </li> <li> <a href="/ai/13098.html" target="_blank" title="可赞AI:AI驱动办公可视化智能工具,一键高效生成文档图表脑图" class="img_box"> <img src="/uploads/20251021/176103600268f746e238bb8.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="可赞AI:AI驱动办公可视化智能工具,一键高效生成文档图表脑图" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13098.html" class="aBlack" target="_blank" title="可赞AI">可赞AI</a></dt> <dd class="cont1 lineTwoOverflow"> 可赞AI,AI驱动的办公可视化智能工具,助您轻松实现文本与可视化元素高效转化。无论是智能文档生成、多格式文本解析,还是一键生成专业图表、脑图、知识卡片,可赞AI都能让信息处理更清晰高效。覆盖数据汇报、会议纪要、内容营销等全场景,大幅提升办公效率,降低专业门槛,是您提升工作效率的得力助手。 </dd> <dd class="cont2">3420次使用</dd> </dl> </li> <li> <a href="/ai/13097.html" target="_blank" title="星月写作:AI网文创作神器,助力爆款小说速成" class="img_box"> <img src="/uploads/20251014/176043000368ee07b3159d6.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="星月写作:AI网文创作神器,助力爆款小说速成" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13097.html" class="aBlack" target="_blank" title="星月写作">星月写作</a></dt> <dd class="cont1 lineTwoOverflow"> 星月写作是国内首款聚焦中文网络小说创作的AI辅助工具,解决网文作者从构思到变现的全流程痛点。AI扫榜、专属模板、全链路适配,助力新人快速上手,资深作者效率倍增。 </dd> <dd class="cont2">4526次使用</dd> </dl> </li> <li> <a href="/ai/13096.html" target="_blank" title="MagicLight.ai:叙事驱动AI动画视频创作平台 | 高效生成专业级故事动画" class="img_box"> <img src="/uploads/20251014/176040000268ed9282edf80.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="MagicLight.ai:叙事驱动AI动画视频创作平台 | 高效生成专业级故事动画" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13096.html" class="aBlack" target="_blank" title="MagicLight">MagicLight</a></dt> <dd class="cont1 lineTwoOverflow"> MagicLight.ai是全球首款叙事驱动型AI动画视频创作平台,专注于解决从故事想法到完整动画的全流程痛点。它通过自研AI模型,保障角色、风格、场景高度一致性,让零动画经验者也能高效产出专业级叙事内容。广泛适用于独立创作者、动画工作室、教育机构及企业营销,助您轻松实现创意落地与商业化。 </dd> <dd class="cont2">3800次使用</dd> </dl> </li> </ul> </div> <!-- 相关文章 --> <div class="rightContBox"> <div class="rightTit"> <a href="/articlelist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">相关文章</div> </div> <ul class="aboutArticleRList"> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/80964.html" class="aBlack" title="Flask框架安装技巧:让你的开发更高效">Flask框架安装技巧:让你的开发更高效</a></dt> <dd> <span class="left">2024-01-03</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/90241.html" class="aBlack" title="Django框架中的并发处理技巧">Django框架中的并发处理技巧</a></dt> <dd> <span class="left">2024-01-22</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/88174.html" class="aBlack" title="提升Python包下载速度的方法——正确配置pip的国内源">提升Python包下载速度的方法——正确配置pip的国内源</a></dt> <dd> <span class="left">2024-01-17</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/113474.html" class="aBlack" title="Python与C++:哪个编程语言更适合初学者?">Python与C++:哪个编程语言更适合初学者?</a></dt> <dd> <span class="left">2024-03-25</span> <span class="right">501浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/120624.html" class="aBlack" title="品牌建设技巧">品牌建设技巧</a></dt> <dd> <span class="left">2024-04-06</span> <span class="right">501浏览</span> </dd> </dl> </li> </ul> </div> </div> </div> <div class="footer"> <div class="footerIn"> <div class="footLeft"> <div class="linkBox"> <a href="/about/1.html" target="_blank" class="aBlack" title="关于我们">关于我们</a> <a href="/about/5.html" target="_blank" class="aBlack" title="免责声明">免责声明</a> <a href="#" class="aBlack" title="意见反馈">意见反馈</a> <a href="/about/2.html" class="aBlack" target="_blank" title="联系我们">联系我们</a> <a href="/send.html" class="aBlack" title="广告合作">内容提交</a> </div> <div class="footTip">Golang学习网:公益在线Go学习平台,帮助Go学习者快速成长!</div> <div class="shareBox"> <span><i class="qq"></i>技术交流群</span> </div> <div class="copyRight"> Copyright 2023 http://www.17golang.com/ All Rights Reserved | <a href="https://beian.miit.gov.cn/" target="_blank" title="备案">苏ICP备2023003363号-1</a> </div> </div> <div class="footRight"> <ul class="encodeList"> <li> <div class="encodeImg"> <img src="/assets/examples/qrcode_for_gh.jpg" alt="Golang学习网"> </div> <div class="tit">关注公众号</div> <div class="tip">Golang学习网</div> </li> <div class="clear"></div> </ul> </div> <div class="clear"></div> </div> </div> <!-- 微信登录弹窗 --> <style> .popupBg .n-error{ color: red; } </style> <div class="popupBg"> <div class="loginBoxBox"> <div class="imgbg"> <img src="/assets/images/leftlogo.jpg" alt=""> </div> <!-- 微信登录 --> <div class="loginInfo encodeLogin" style="display: none;"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="changeLoginType cursorPointer create_wxqrcode" onclick="$('.loginInfo').hide();$('.passwordLogin').show();"> <div class="tip">密码登录在这里</div> </div> <div class="encodeInfo"> <div class="tit"><i></i> 微信扫码登录或注册</div> <div class="encodeImg"> <span id="wx_login_qrcode"><img src="/assets/examples/code.png" alt="二维码"></span> <!-- <div class="refreshBox"> <p>二维码失效</p> <button type="button" class="create_wxqrcode">刷新1111</button> </div> --> </div> <div class="tip">打开微信扫一扫,快速登录/注册</div> </div> <div class="beforeLoginTip">登录即同意 <a href="#" class="aBlue" title="用户协议">用户协议</a> 和 <a href="#" class="aBlue" title="隐私政策">隐私政策</a></div> </div> <!-- 密码登录 --> <div class="loginInfo passwordLogin"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="changeLoginType cursorPointer create_wxqrcode" onclick="$('.loginInfo').hide();$('.encodeLogin').show();"> <div class="tip">微信登录更方便</div> </div> <div class="passwordInfo"> <ul class="logintabs selfTabMenu"> <li class="selfTabItem loginFormLi curr">密码登录</li> <li class="selfTabItem registerFormBox ">注册账号</li> </ul> <div class="selfTabContBox"> <div class="selfTabCont loginFormBox" style="display: block;"> <form name="form" id="login-form" class="form-vertical form" method="POST" action="/index/user/login"> <input type="hidden" name="url" value="//www.17golang.com/article/358965.html"/> <input type="hidden" name="__token__" value="cf89d3af6694abae22d095c52c0a0774" /> <div class="form-group" style="height:70px;"> <input class="form-control" id="account" type="text" name="account" value="" data-rule="required" placeholder="邮箱/用户名" autocomplete="off"> </div> <div class="form-group" style="height:70px;"> <input class="form-control" id="password" type="password" name="password" data-rule="required;password" placeholder="密码" autocomplete="off"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" data-rule="required;length(4)" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <img src="/captcha.html" width="100" height="45" onclick="this.src = '/captcha.html?r=' + Math.random();"/> </span> </div> <div class="other"> <a href="#" class="forgetPwd aGray" onclick="$('.loginInfo').hide();$('.passwordForget').show();" title="忘记密码">忘记密码</a> </div> <div class="loginBtn mt25"> <button type="submit">登录</button> </div> </form> </div> <div class="selfTabCont registerFormBox" style="display: none;"> <form name="form1" id="register-form" class="form-vertical form" method="POST" action="/index/user/register"> <input type="hidden" name="invite_user_id" value="0"/> <input type="hidden" name="url" value="//www.17golang.com/article/358965.html"/> <input type="hidden" name="__token__" value="cf89d3af6694abae22d095c52c0a0774" /> <div class="form-group" style="height:70px;"> <input type="text" name="email" id="email2" data-rule="required;email" class="form-control" placeholder="邮箱"> </div> <div class="form-group" style="height:70px;"> <input type="text" id="username" name="username" data-rule="required;username" class="form-control" placeholder="用户名必须3-30个字符"> </div> <div class="form-group" style="height:70px;"> <input type="password" id="password2" name="password" data-rule="required;password" class="form-control" placeholder="密码必须6-30个字符"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" data-rule="required;length(4)" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <img src="/captcha.html" width="100" height="45" onclick="this.src = '/captcha.html?r=' + Math.random();"/> </span> </div> <div class="loginBtn"> <button type="submit">注册</button> </div> </form> </div> </div> </div> <div class="beforeLoginTip">登录即同意 <a href="https://www.17golang.com/about/3.html" target="_blank" class="aBlue" title="用户协议">用户协议</a> 和 <a href="https://www.17golang.com/about/4.html" target="_blank" class="aBlue" title="隐私政策">隐私政策</a></div> </div> <!-- 重置密码 --> <div class="loginInfo passwordForget"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="returnLogin cursorPointer" onclick="$('.passwordForget').hide();$('.passwordLogin').show();">返回登录</div> <div class="passwordInfo"> <ul class="logintabs selfTabMenu"> <li class="selfTabItem">重置密码</li> </ul> <div class="selfTabContBox"> <div class="selfTabCont"> <form id="resetpwd-form" class="form-horizontal form-layer nice-validator n-default n-bootstrap form" method="POST" action="/api/user/resetpwd.html" novalidate="novalidate"> <div style="height:70px;"> <input type="text" class="form-control" id="email" name="email" value="" placeholder="输入邮箱" aria-invalid="true"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <a href="javascript:;" class="btn btn-primary btn-captcha cursorPointer" style="background: #2080F8; border-radius: 4px; color: #fff; padding: 12px; position: absolute;" data-url="/api/ems/send.html" data-type="email" data-event="resetpwd">发送验证码</a> </span> </div> <input type="password" class="form-control" id="newpassword" name="newpassword" value="" placeholder="请输入6-18位密码"> <div class="loginBtn mt25"> <button type="submit">重置密码</button> </div> </form> </div> </div> </div> </div> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?3dc5666f6478c7bf39cd5c91e597423d"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script src="/assets/js/require.js" data-main="/assets/js/require-frontend.js?v=1671101972"></script> </body> </html>