ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    使用 node pipe 批量下载文件

    Jan 19, 202314 min read
    const fs = require('fs')
    const request = require('request')
    // 使用 node pipe 批量下载文件
    const down = (url, path) => {
        // 获取url query audio 参数
        const audio = url.split('audio=')[1]
        // 创建文件流
        const stream = fs.createWriteStream(audio + '.mp3')
        // 发送请求
        request(url).pipe(stream).on('close', err => {
            if (err) {
                console.log(err)
            }
            console.log(audio + '下载完成')
        })
    }
    
    down("https://dict.youdao.com/dictvoice?type=%E7%BE%8E%E9%9F%B3&audio=hello")
    

    相关文章

    启用通过 HTTPS 的 SSH 连接

    通过在 SSH 配置文件中设置 `Host github.com`、`Hostname ssh.github.com`、`Port 443` 和 `User git`,可以启用通过 HTTPS 的 SSH 连接到 GitHub.com。

    Nextjs 获取数据的方式

    Next.js提供了四种数据获取API(getStaticProps、getStaticPaths、getServerSideProps、已弃用的getInitialProps),用于在构建时或服务器端动态生成页面内容,以优化性能和用户体验。

    go mod 相关命令小抄

    《go mod 相关命令小抄》总结了包括下载、整理、查看、初始化、编辑、导出、校验和清理模块等操作的go mod命令。

    Speedtest带宽测速

    使用Speedtest工具通过运行特定命令在Linux系统中测量主机的上传和下载带宽。

    Go标准库新增了Error Wrapping功能

    AI语言模型声明缺乏Go语言技术知识,无法深入分析该话题。