Processing HTML File
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 206   1
URL.หัวข้อ / URL
Processing HTML File

ถามไว้ที่ 
http://www.access-programmers.co.uk/forums/showthread.php?s=&postid=109464#post109464 
 
ดังนี้ครับ 
 
Hi,  
 
I have more than 1000 HTML files containing the same header which is useless for me.  
 
Is there a way to open the HTML file in text mode, and to delete a string (a  
sequention of chars which are the useless tags) from it, than save it ?  
 
I plan to make a loop in order to "clean up" all the files.  
 
Any replies would be greatly appreciated.  
 
ต้องการลบข้อความบางอย่างในไฟล์ HTML ออกจะทำอย่างไร เมื่อต้องทำเป็นพันๆ ไฟล์ 
 
ผมเคยเขียนโค้ดเพื่อทำการเปลี่ยนข้อความของ HTML ของกระทู้ถามตอบ Access ในหลายๆ ที่ ซึ่งผมไป Save มา จำนวนหลายหมื่นไฟล์ ผมต้องการจะไปเอาข้อความที่โฆษณา หรือข้อความที่ไม่สำคัญออก ผมเลยต้องเขียนโค้ดขึ้นมา แล้ววนไปอ่านไฟล์ในโฟล์เดอร์เป้าหมาย ค้นหาข้อความ หรือ Tag ที่ต้องการจะเอาออก ตัดมันทิ้ง แล้วเขียนเป็นไฟล์ใหม่ แล้วไปลบไฟล์เดิมทิ้ง 
 
ลองดูโค้ดข้างล่างครับ 
 
Function CleanUp() 
Dim strLink As String 
Dim strAllText As String 
Dim I As Integer 
Dim strOld As String, strNew As String 
 
'strOld = "h:\html\" & strHTML 
'strNew = "h:\html\old\" & strHTML 
 
Open "h:\html\120757.html" For Input As #1 
Open "h:\html\new120757.html" For Output As #2 
I = 0 
    Do While Not EOF(1) 
        Line Input #1, strLink 
        strAllText = strLink 
            ' Start from now on 
            If strAllText = "" Then 
                strAllText = "" 
                I = 1 
            ElseIf strAllText = "