如果一个文件中的一个更改DIV元素在所有其他html文件中自动更改,我该怎么做呢



我的网站上有一个最近发布的区域。它在我网站的所有网页上都是一样的,甚至在同一个位置。我想要一些东西,如果我在一个文件中更改它,它会在所有其他html文件中自动更新。我正在使用github来托管我的网站。

<div class="recent">
<h3>Recent Post</h3>
<div class="post1">
<a href="sanandrease.html">
<img src="images/sanandrease.jpeg" id="img1">
<p class="text1">Grand Theft Auto : San Andrease | Free Download | Highly Compressed </p>
</a>
</div>

<div class="post2">
<a href="gta3.html">
<img src="images/gta3.jpeg" id="img2">
<p class="text3">Grand Theft Auto 3 | Free <br>Download | Highly Compressed </p>
</a>
</div>

<div class="post3">
<a href="gta4.html">
<img src="images/gta4.jpeg" id="img3">
<p class="text3">Grand Theft Auto 4 | Free <br>Download | Highly Compressed </p>
</a>
</div>
</div>

您可以使用搜索并用Notepad++替换指定工作区的位置(这可以应用于的文件夹(。

Python(任何操作系统(对于那些使用Python 3.5+的人,现在可以通过使用**和递归标志递归地使用glob。

这里有一个例子,将hello替换为world,用于所有.txt文件:

for filepath in glob.iglob('./**/*.txt', recursive=True): with open(filepath) as file: s = file.read() s = s.replace('hello', 'world') with open(filepath, "w") as file: file.write(s)

在linux中,您可以使用以下方法:rpl

对于大多数快速使用,您可能会发现命令rpl更容易记住。

将所有.txt文件上的foo替换为bar:rpl -v foo bar '*.txt'

模拟递归地用所有.txt文件中的bar替换regex foo.*:rpl --dry-run 'foo.*' bar '**/*.txt'

您可能需要安装它(apt-get-install-rpl或类似程序(。

相关内容

最新更新