gpt4 book ai didi

javascript - 使用 Grunt 检索 html 主体的内容

转载 作者:行者123 更新时间:2023-11-28 15:29:06 26 4
gpt4 key购买 nike

是否有一个 grunt 任务可以抓取 html 正文的内容并将其放入单独的文件中?

<html>
<body>
<h1>Grab this</h1>
<h2>And this</h2>
</body>
</html>

最佳答案

您可以使用 Grunt 的“复制文件部分”来选择正文。

文档在这里。 https://www.npmjs.com/package/grunt-copy-part-of-file

例如

grunt.initConfig({
copy_part_of_file: {
simple_replace_scripts: {
options: {
sourceFileStartPattern: '<body>',
sourceFileEndPattern: '</body>',
destinationFileStartPattern: '',
destinationFileEndPattern: ''
},
files: {
'test/fixtures/simple-destination.html': ['test/fixtures/simple-source.html']
}
}
},
})

关于javascript - 使用 Grunt 检索 html 主体的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28054129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com