Re: [问题]epub档案 请问 如何 搜寻并取代 所有tag

楼主: shadowjohn (转角遇到爱)   2016-09-19 08:56:40
※ 引述《Nitschke (下载至死)》之铭言:
: 请问要 下载什么软件 及 方法?
: Thank thank everyone
: find and replace all <span class="bold">*</span> with <h2 >*</h2 >
: while keeping the sub tag, <span class="underline">*</span> unchanged.
: <span class="bold">
: <span class="underline">
: *contents are different
: </span>
: </span>
: To
: <h2>
: <span class="underline">
: *contents are different
: </span>
: </h2>
: ※ 编辑: Nitschke (61.18.110.123), 09/18/2016 17:48:49
: 推 CauseSam: 居然还有人继续投入,推!! 09/18 19:15
epub档是可以用zip反解
里面应该就是html、css编成的内容
如果你有很多个档案应该是可以自写个小程式来作这件事
1、循环跑所有的epub
2、解压缩到tmp资料夹
3、读取html或htm档
4、搜寻tag并取代写回html、htm档
5、重新压回zip取名epub
至于工具的话,会php就推荐你用simplehtmldom
写法应该就...
<?php
include "simplehtmldom/smiplehtmldom.php";
$html = file_get_html('a.html'); //epub html
for($i=0;$i< count($html->find("span[class='bold']"));$i++)
{
$dom = $html->find("span[class='bold']")[$i];
$dom->tag="h2";
$dom->class=null;
$html->find("span[class='bold']")[$i]=$dom;
}
$html->save('a.html');
参考
http://simplehtmldom.sourceforge.net/manual.htm#section_quickstart
没验证不知道对不对 XD

Links booklink

Contact Us: admin [ a t ] ucptt.com