Re: [問題]epub檔案 請問 如何 搜尋並取代 所有tag

看板Web_Design作者 (轉角遇到愛)時間7年前 (2016/09/19 08:56), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
※ 引述《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 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.134.48.253 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1474246606.A.FDA.html
文章代碼(AID): #1NtpVE_Q (Web_Design)