<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>编程 &#8211; 慢城市快生活</title>
	<atom:link href="http://www.gwren.com/tag/%E7%BC%96%E7%A8%8B/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gwren.com</link>
	<description></description>
	<lastBuildDate>Sat, 15 Mar 2025 03:53:43 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>编程小白的逆袭！找豆包实现信息提取V1.2，超神了💥</title>
		<link>http://www.gwren.com/2025/02/%e7%bc%96%e7%a8%8b%e5%b0%8f%e7%99%bd%e7%9a%84%e9%80%86%e8%a2%ad%ef%bc%81%e6%89%be%e8%b1%86%e5%8c%85%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e7%88%ac%e8%99%abv1-2%ef%bc%8c%e8%b6%85%e7%a5%9e%e4%ba%86/</link>
					<comments>http://www.gwren.com/2025/02/%e7%bc%96%e7%a8%8b%e5%b0%8f%e7%99%bd%e7%9a%84%e9%80%86%e8%a2%ad%ef%bc%81%e6%89%be%e8%b1%86%e5%8c%85%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e7%88%ac%e8%99%abv1-2%ef%bc%8c%e8%b6%85%e7%a5%9e%e4%ba%86/#comments</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 19 Feb 2025 01:40:43 +0000</pubDate>
				<category><![CDATA[AI使用]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[食品安全标准]]></category>
		<guid isPermaLink="false">http://www.gwren.com/?p=239</guid>

					<description><![CDATA[需求背景 宝子们👋，今天必须来给大家分享我这个编程小白的神奇蜕变历程！最近因为要建立AI个人知识库的需要，我得&#8230; <a href="http://www.gwren.com/2025/02/%e7%bc%96%e7%a8%8b%e5%b0%8f%e7%99%bd%e7%9a%84%e9%80%86%e8%a2%ad%ef%bc%81%e6%89%be%e8%b1%86%e5%8c%85%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e7%88%ac%e8%99%abv1-2%ef%bc%8c%e8%b6%85%e7%a5%9e%e4%ba%86/" class="more-link">继续阅读 <span class="screen-reader-text">编程小白的逆袭！找豆包实现信息提取V1.2，超神了💥</span></a>]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">需求背景</h2>



<p>宝子们<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f44b.png" alt="👋" class="wp-smiley" style="height: 1em; max-height: 1em;" />，今天必须来给大家分享我这个编程小白的神奇蜕变历程！最近因为要建立AI个人知识库的需要，我得收集大量食品国家标准信息，包含标准名称、状态、发布实施日期等等，最重要是是否现行有效。要是手动去一个个网站复制粘贴，那工作量简直大到让人崩溃<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f62b.png" alt="😫" class="wp-smiley" style="height: 1em; max-height: 1em;" />，所以我决定试试爬虫程序！但我之前完全没接触过编程，两眼抓下就像无头苍蝇一样乱撞。</p>



<h2 class="wp-block-heading">遇见豆包</h2>



<p>就在我焦头烂额的时候，我发现了豆包这个超厉害的“编程神器”<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9e0.png" alt="🧠" class="wp-smiley" style="height: 1em; max-height: 1em;" />。我就抱着试试看的心态，把我的需求一股脑儿全告诉了它：想要从特定网站爬取食品标准数据，数据导出的格式和顺序得按照我的要求来，还要能断点续传，抓取完成后能自动分割表格、转换格式……这些要求听起来就很复杂，我自己都说得有点心虚，没想到豆包居然稳稳接住了！</p>



<h2 class="wp-block-heading">制作过程</h2>



<p>和豆包的“对话”就像一场奇妙的冒险。我提出想法，它就给出代码示例，我有不明白的地方，它就耐心解释，一步一步引导我。每一次修改代码、调整功能，都像是在搭建一座属于自己的编程小城堡<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f3f0.png" alt="🏰" class="wp-smiley" style="height: 1em; max-height: 1em;" />。它不仅给我提供代码，还会告诉我每一行代码的作用，就像给我一把把打开编程世界大门的钥匙<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f511.png" alt="🔑" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>



<h2 class="wp-block-heading">最终成果</h2>



<p>经过一番努力，我的数据爬虫V1.2版本成功诞生啦<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" />！它不仅能快速准确地抓取我需要的数据，导出表格的格式也完全符合我的预期。而且，分割表格和转换格式这些复杂的操作，它都能一键搞定，效率超高，直接把我从繁琐的数据收集工作中解放出来！现在，我只要运行这个程序，就能轻松获取想要的信息，节省了超多时间和精力。</p>



<pre class="wp-block-preformatted"># 这里展示完整代码，但实际内容省略啦
import pandas as pd
from selenium import webdriver
#......
</pre>



<h2 class="wp-block-heading">总结</h2>



<p>真的太感谢豆包啦！它就像我编程路上的超级导师，对编程小白超级友好。以前觉得编程遥不可及，现在在豆包的帮助下，我也能写出实用的程序，这种成就感简直无法言喻！如果你也和我一样，是个编程小白，又有编程需求，那就快去试试豆包吧，相信你也会收获满满的惊喜<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f496.png" alt="💖" class="wp-smiley" style="height: 1em; max-height: 1em;" />！</p>
]]></content:encoded>
					
					<wfw:commentRss>http://www.gwren.com/2025/02/%e7%bc%96%e7%a8%8b%e5%b0%8f%e7%99%bd%e7%9a%84%e9%80%86%e8%a2%ad%ef%bc%81%e6%89%be%e8%b1%86%e5%8c%85%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e7%88%ac%e8%99%abv1-2%ef%bc%8c%e8%b6%85%e7%a5%9e%e4%ba%86/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>我和AI死磕网页保存脚本的全过程</title>
		<link>http://www.gwren.com/2025/02/%e6%88%91%e5%92%8cai%e6%ad%bb%e7%a3%95%e7%bd%91%e9%a1%b5%e6%8a%93%e5%8f%96%e8%84%9a%e6%9c%ac%e7%9a%84%e5%85%a8%e8%bf%87%e7%a8%8b/</link>
					<comments>http://www.gwren.com/2025/02/%e6%88%91%e5%92%8cai%e6%ad%bb%e7%a3%95%e7%bd%91%e9%a1%b5%e6%8a%93%e5%8f%96%e8%84%9a%e6%9c%ac%e7%9a%84%e5%85%a8%e8%bf%87%e7%a8%8b/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 12 Feb 2025 16:39:04 +0000</pubDate>
				<category><![CDATA[AI使用]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[脚本]]></category>
		<guid isPermaLink="false">http://www.gwren.com/?p=229</guid>

					<description><![CDATA[👀宝子们，我和AI死磕网页抓取脚本的全过程！ 最近我被一个需求折磨得死去活来，就是要搞一个能抓取网页内容并保存&#8230; <a href="http://www.gwren.com/2025/02/%e6%88%91%e5%92%8cai%e6%ad%bb%e7%a3%95%e7%bd%91%e9%a1%b5%e6%8a%93%e5%8f%96%e8%84%9a%e6%9c%ac%e7%9a%84%e5%85%a8%e8%bf%87%e7%a8%8b/" class="more-link">继续阅读 <span class="screen-reader-text">我和AI死磕网页保存脚本的全过程</span></a>]]></description>
										<content:encoded><![CDATA[
<p> <h1><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f440.png" alt="👀" class="wp-smiley" style="height: 1em; max-height: 1em;" />宝子们，我和AI死磕网页抓取脚本的全过程！</h1>
    <p>最近我被一个需求折磨得死去活来，就是要搞一个能抓取网页内容并保存的脚本。你们能想象吗？我本来以为就是写几行代码的事儿，结果折腾了两天，现在还只是个半自动的！今天就来给大家唠唠我和AI死磕这个脚本的全过程。</p>
    <h2>需求初现：简单任务？大错特错！</h2>
    <p>一开始，需求看似挺简单，就是在网站上，实现目录页选择保存正文页面为MD格式，还要能下载附件。我心想，这有啥难的，不就是写个Tampermonkey脚本嘛！于是我信心满满地开始动手，结果，现实给了我狠狠一巴掌<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f62b.png" alt="😫" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>
    <h2>艰难探索：一个问题接着一个问题</h2>
    <h3>目录页按钮与链接获取</h3>
    <p>先是目录页，我得判断当前页面是不是目录页，然后在页面上添加按钮。这一步就不顺利，我得精确找到目录页的特征。好不容易找到了，添加按钮的时候又遇到问题，按钮位置怎么调都不满意，一会儿在中间偏左，一会儿又被其他元素遮挡。获取正文链接列表也不轻松，网页结构稍微复杂点，<code>querySelector</code>就找不到元素，我在那对着代码抓耳挠腮，头发都快薅掉一把了<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f62d.png" alt="😭" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>
    <img decoding="async" src="http://www.gwren.com/wp-content/uploads/2025/02/image.png" alt="抓狂表情包" style="max-width: 100%; height: auto;">
    <h3>正文页附件下载难题</h3>
    <p>正文页的问题更多！保存附件时，获取附件链接就很麻烦。链接有时候是相对的，有时候是绝对的，而且基于目录页生成的绝对链接根本不对。我就和AI一起想办法，尝试了好多方法。用<code>new URL</code>来生成绝对链接，结果还是有偏差。后来又试着直接打开正文页面获取链接，代码写得那叫一个复杂，各种异步操作、事件监听，脑袋都快炸了。</p>
    <img decoding="async" src="http://www.gwren.com/wp-content/uploads/2025/02/image-1.png" alt="头晕表情包" style="max-width: 100%; height: auto;">
    <h2>AI助力：希望与挫折并存</h2>
    <p>在这个过程中，AI真的是我的救星，但也让我又爱又恨。我把问题一股脑地抛给它，它每次都能很快给出代码建议。比如修改获取附件链接的代码，它能给出几种不同的思路，像用正则表达式匹配、XPath查询等。但是有些代码放到我的项目里就报错，还得我自己慢慢调试。有时候它理解错我的意思，给的代码和我的需求完全不沾边，真的让人哭笑不得<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f605.png" alt="😅" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>
    <h2>成果与展望：继续加油！</h2>
    <p>经过这两天的努力，虽然还没实现全自动，但也有了一些成果。现在目录页能选择保存正文页面为MD格式了，部分附件也能下载了。看着这些小小的进步，心里还是有点成就感的。不过，距离完全实现全自动还有很长的路要走。我打算继续和AI合作，把剩下的问题解决掉。</p>
    <p>代码就懒得展示了</p>
       <p>#网页抓取 #Tampermonkey脚本 #AI编程 #代码调试</p></p>
]]></content:encoded>
					
					<wfw:commentRss>http://www.gwren.com/2025/02/%e6%88%91%e5%92%8cai%e6%ad%bb%e7%a3%95%e7%bd%91%e9%a1%b5%e6%8a%93%e5%8f%96%e8%84%9a%e6%9c%ac%e7%9a%84%e5%85%a8%e8%bf%87%e7%a8%8b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>找豆包写了个网页另存为docx文件的篡改猴 (Tampermonkey) 脚本，然后又叫她把求助过程写了篇文章</title>
		<link>http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/</link>
					<comments>http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 11 Feb 2025 07:10:36 +0000</pubDate>
				<category><![CDATA[AI使用]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[豆包]]></category>
		<guid isPermaLink="false">http://www.gwren.com/?p=226</guid>

					<description><![CDATA[🤩用豆包轻松搞定 Tampermonkey 脚本！ 🤩用豆包轻松搞定 Tampermonkey 脚本！ 宝子们&#8230; <a href="http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/" class="more-link">继续阅读 <span class="screen-reader-text">找豆包写了个网页另存为docx文件的篡改猴 (Tampermonkey) 脚本，然后又叫她把求助过程写了篇文章</span></a>]]></description>
										<content:encoded><![CDATA[
<p><!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f929.png" alt="🤩" class="wp-smiley" style="height: 1em; max-height: 1em;" />用豆包轻松搞定 Tampermonkey 脚本！</title>
</head>
<body>

    <h1><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f929.png" alt="🤩" class="wp-smiley" style="height: 1em; max-height: 1em;" />用豆包轻松搞定 Tampermonkey 脚本！</h1>

    <p>宝子们<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f44b.png" alt="👋" class="wp-smiley" style="height: 1em; max-height: 1em;" />，今天来给大家分享一下我是如何借助豆包编程助手编写 Tampermonkey 脚本的，学会了之后真的能让上网变得超有趣又高效<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f44f.png" alt="👏" class="wp-smiley" style="height: 1em; max-height: 1em;" />！</p>

    <h2><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f388.png" alt="🎈" class="wp-smiley" style="height: 1em; max-height: 1em;" />什么是 Tampermonkey 脚本？</h2>
    <p>Tampermonkey 是一款超强大的浏览器扩展，它可以让我们通过编写脚本来自定义网页的功能和外观。比如说，你可以去除网页广告、自动填充表单、批量下载图片等等<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9d0.png" alt="🧐" class="wp-smiley" style="height: 1em; max-height: 1em;" />。有了它，上网就像开了挂一样！</p>

    <h2><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f9d1-200d-1f4bb.png" alt="🧑‍💻" class="wp-smiley" style="height: 1em; max-height: 1em;" />准备工作</h2>
    <ol>
        <li>安装 Tampermonkey 扩展：在你的浏览器扩展商店（像 Chrome、Edge 等）里搜索“Tampermonkey”，然后点击安装就好啦。安装完成后，浏览器右上角会出现一个小猴子图标<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f435.png" alt="🐵" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</li>
        <li>打开豆包编程助手：就是咱们超厉害的豆包啦，它能帮你快速生成脚本代码<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f60e.png" alt="😎" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</li>
    </ol>

    <h2><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" />开始编写脚本</h2>
    <p>我以编写一个“网页另存为 Word 文档”的脚本为例，给大家详细说说步骤<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f447.png" alt="👇" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>

    <h3>1. 告诉豆包需求</h3>
    <p>在和豆包的对话框里，清晰地描述你想要实现的功能。比如我当时就说：“帮我编写一段网页另存为 word 文档的 Tampermonkey 代码，要求保留主页面的所有元素。要求在页面顶端增加一个另存按钮，另外自动命名为网页名称”。把需求说得越详细，豆包给出的代码就越符合你的心意<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f61c.png" alt="😜" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>

    <h3>2. 获取代码</h3>
    <p>豆包很快就会生成对应的代码，像这样：</p>
    <pre><code>
// ==UserScript==
// @name         Save Web Page as Word
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add a button to save the web page as a Word document.
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 创建一个按钮元素
    const saveButton = document.createElement('button');
    saveButton.textContent = '另存为 Word';
    saveButton.style.position = 'fixed';
    saveButton.style.top = '10px';
    saveButton.style.left = '10px';
    saveButton.style.zIndex = '9999';

    // 将按钮添加到页面
    document.body.appendChild(saveButton);

    // 为按钮添加点击事件监听器
    saveButton.addEventListener('click', function() {
        // 获取网页标题
        const pageTitle = document.title;

        // 获取页面的 HTML 内容
        const htmlContent = document.documentElement.outerHTML;

        // 创建一个 Blob 对象，将 HTML 内容转换为二进制数据
        const blob = new Blob([htmlContent], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });

        // 创建一个 URL 对象
        const url = URL.createObjectURL(blob);

        // 创建一个链接元素
        const link = document.createElement('a');
        link.href = url;
        link.download = `${pageTitle}.docx`;

        // 模拟点击链接以下载文件
        link.click();

        // 释放 URL 对象
        URL.revokeObjectURL(url);
    });
})();
    </code></pre>

    <h3>3. 创建并粘贴脚本</h3>
    <ol>
        <li>点击浏览器右上角的 Tampermonkey 小猴子图标，选择“创建一个新脚本”。</li>
        <li>把豆包给的代码复制粘贴到 Tampermonkey 的脚本编辑器里。</li>
        <li>点击编辑器左上角的“保存”按钮<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4be.png" alt="💾" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</li>
    </ol>

    <h3>4. 测试脚本</h3>
    <p>打开任意一个网页，你会发现页面顶端出现了“另存为 Word”的按钮。点击这个按钮，网页就会保存为 Word 文档，文件名就是网页的标题<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f60f.png" alt="😏" class="wp-smiley" style="height: 1em; max-height: 1em;" />。</p>

    <h2><img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f4a1.png" alt="💡" class="wp-smiley" style="height: 1em; max-height: 1em;" />小技巧和注意事项</h2>
    <ul>
        <li>如果代码运行有问题，仔细检查一下需求描述是否准确，或者跟豆包说清楚问题，让它帮你修改代码。</li>
        <li>不同的网页可能有不同的结构和安全策略，有些脚本可能在某些网页上无法正常工作，这时候就需要进一步调整代码啦。</li>
    </ul>

    <p>宝子们，赶紧动手试试用豆包编写 Tampermonkey 脚本吧，让你的上网体验更上一层楼<img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f970.png" alt="🥰" class="wp-smiley" style="height: 1em; max-height: 1em;" />！</p>

    <p>#Tampermonkey #脚本编写 #豆包编程助手 #上网技巧</p>

</body>
</html></p>
]]></content:encoded>
					
					<wfw:commentRss>http://www.gwren.com/2025/02/%e6%89%be%e8%b1%86%e5%8c%85%e5%86%99%e4%ba%86%e4%b8%aa%e7%bd%91%e9%a1%b5%e5%8f%a6%e5%ad%98%e4%b8%badocx%e6%96%87%e4%bb%b6%e7%9a%84%e7%af%a1%e6%94%b9%e7%8c%b4-tampermonkey-%e8%84%9a%e6%9c%ac/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
