使用cmd/batch文件将文本字符串添加到html文档中
我想在html文档中添加一串文本。使用cmd/batch文件将文本字符串添加到html文档中,html,batch-file,cmd,command-prompt,Html,Batch File,Cmd,Command Prompt,我想在html文档中添加一串文本。 我的网站有一个“更新”部分,你可以看到他们开车去了哪里。(这是一些自行车手的网站) 我想这样做,这样我爸爸只需要打开一个bat文件,键入一些信息,然后它就会将字符串添加到html文档中。 我目前使用“表格”作为布局。 代码如下: <tr style="mso-yfti-irow:34"> <td valign="top" style="width:180;padding-left:3.5pt; padding-light:3.5pt
我的网站有一个“更新”部分,你可以看到他们开车去了哪里。(这是一些自行车手的网站)
我想这样做,这样我爸爸只需要打开一个bat文件,键入一些信息,然后它就会将字符串添加到html文档中。
我目前使用“表格”作为布局。
代码如下:
<tr style="mso-yfti-irow:34">
<td valign="top" style="width:180;padding-left:3.5pt; padding-light:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">DATE</font>
</td>
<td valign="top" style="width:500;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">LOCATION</font></td>
<td valign="top" style="width:523;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">AMOUNT</font>
</td>
</tr>
日期
位置
数量
当前网站
<html>
<head>
Some things here....
</head>
<body>
<div>
More things here
</div>
<table>
the table/the place where new text should be added
</table>
A bit more
</body>
</html>
这里有些东西。。。。
这里有更多的东西
表格/应添加新文本的位置
多一点
我想做的是,我可以用这个代码创建一个bat文件
echo off
set /p Date="Date: "
set /p Location="Location: "
set /p Amount="Amount: "
(some command here to add it)
<tr style="mso-yfti-irow:34">
<td valign="top" style="width:180;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">%Date%</font></td>
<td valign="top" style="width:500;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">%Location%</font></td>
<td valign="top" style="width:523;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">%Amount%</font></td>
</tr>
Exit
echo关闭
set/p Date=“日期:”
设置/p位置=“位置:”
设置/p金额=“金额:”
(此处有一些命令用于添加它)
%日期%
%位置%
%金额%
出口
新文本应始终添加在表的底部,而不是html文档的底部
行号也将始终更改
我希望我解释得足够清楚,如果你有什么不明白的地方,那就写吧,然后我会试图澄清一下,听起来你已经写了bat脚本来提示你爸爸输入值了。因此,我将重点介绍如何将它们插入html页面 在当前html文件中,更改表格末尾的格式,将最后一个直接放在
bat文件将调用此脚本以替换&qout;与实际“html文件中的字符。是否将托管此文件?”?那么你可以使用一点PHP来发挥你的优势。是的,它将被托管在ftp服务器上。不要用批处理文件编辑HTML文件,使用一种本机支持HTML的语言…ascgipfl像什么?它确实有效,有点所以我让它工作了,但是.html文件无法读取“qout as”,因此它使布局看起来很奇怪。是否可以让powershell遍历html文档,并将其替换为“类似的内容”我现在使用的脚本powershell-命令替换“"”“很抱歉,我看起来很乱,但我不能再发一篇帖子了。。。因此,我做了一个看起来有点奇怪的评论,希望你仍然理解我找到了一个解决方案,并将简短地更新上述文本。我已经更新了我的答案,以解决格式问题。让我知道它是如何工作的。
</tr></table>
(some command here to add it)
<tr style="mso-yfti-irow:34">
<td valign="top" style="width:180;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">%Date%</font></td>
<td valign="top" style="width:500;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">%Location%</font></td>
<td valign="top" style="width:523;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5">
<font size="4">%Amount%</font></td>
</tr>
powershell -command "(Get-Content Name_of_File.html) -replace '</tr></table>', '<tr style="mso-yfti-irow:34"> <td valign="top" style="width:180;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5"><font size="4">%Date%</font></td><td valign="top" style="width:500;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5"><font size="4">%Location%</font></td><td valign="top" style="width:523;padding-left:3.5pt; padding-right:3.5pt; padding-top:0cm; padding-bottom:0cm" height="5"><font size="4">%Amount%</font></td></tr></table>' | Set-Content Name_of_File.html"
Powershell.exe -executionpolicy remotesigned -File replace_quot.ps1
(Get-Content Name_of_File.html) -replace '"', '"' | set-content Name_of_File.html