Jump to content

To delete all the html comment?


Recommended Posts

To find out how all the html comments are deleted and size. ?

#include <Array.au3>
#include <String.au3>
#include <File.au3>
#include <Inet.au3>
$aSiteUrl = "https://www.autoitscript.com/forum/index.php"

    For $i = 1 To UBound($aSiteUrl)
            $sitenamestr = StringRegExp($aSiteUrl[$i], 'https?://(?:www.)?([^.]+)', 3)
            $sitenames = $sitenamestr[0]
            $downloadtemp = @ScriptDir & '\older\' & $sitenames & '.php'
            $newdir = @ScriptDir & '\newer\' & $sitenames & '.php'
            $inetgetsites = InetGet($aSiteUrl[$i], $downloadtemp, 1, 1)
            $webfileread = FileRead($downloadtemp[$i])
            $Searchhtmlcomment = StringRegExp($webfileread[$i],'\<!--(.+?)-->',1)
        If StringInStr($Searchhtmlcomment[$i], "<!--") Then
        $htmlcommentDelete = StringRegExpReplace($webfileread[$i], "<[\/\!].*?>", "")

        $ext = $sitenames & '.php'
        $array = _FileListToArray($downloadtemp, $ext, $FLTA_FILES)

For $i = 1 To $array[0]
FileCopy($downloadtemp & "\" & $array[$i], $newdir, $FC_OVERWRITE)
Next
        EndIf
        $sizecontrol = FileGetSize($downloadtemp)
         ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sizecontrol[$i] = ' & $sizecontrol[$i] & @CRLF & '>Error code: ' & @error & @CRLF)
Next

 

Link to comment
Share on other sites

How can I check the size later?

#include <File.au3>
#include <Array.au3>
#include <Inet.au3>
#include <String.au3>

Global $readlist = FileRead(@ScriptDir & "\sitelist.txt")

_firstdownloaded()

Func _firstdownloaded()
    Local $olddir = @ScriptDir & '\old\'
    Local $sitelisturl = StringSplit(StringStripCR($readlist), @LF)
        For $i = 1 To UBound($sitelisturl) - 1
            $sitenamestr = StringRegExp($sitelisturl[$i], 'https?://(?:www.)?([^.]+)', 3)
            $sitenames = $sitenamestr[0]
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sitenames = ' & $sitenames & @CRLF & '>Error code: ' & @error & @CRLF)
            $downloadtemp = @ScriptDir & '\old\' & $sitenames & '.xml'
            If FileExists(@ScriptDir & "\old" & $downloadtemp) Then
                $inetgetsites = InetGet($sitelisturl[$i], $downloadtemp, 1, 1)
            Else
                DirCreate(@ScriptDir & "\" & "old")
                $inetgetsites = InetGet($sitelisturl[$i], $downloadtemp, 1, 1)
            EndIf
            $olderSize = FileGetSize($downloadtemp)
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : olderSize = ' & $olderSize & @CRLF & '>Error code: ' & @error & @CRLF)
$ext = $sitenames & '.xml'
$array = _FileListToArray($olddir, $ext, $FLTA_FILES)
For $i = 1 To $array[0]
    $openFile = FileOpen($olddir & $array[$i], 1)
    $sFileRead = FileRead($openFile)
    If StringInStr($sFileRead, "<!--") Then
    $htmlcommentDelete = StringRegExpReplace($sFileRead[$i], '(?s)<!--.*?-->', "")
FileClose($openFile[$i])
    Else
    $newerSize = FileGetSize($downloadtemp)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newerSize = ' & $newerSize & @CRLF & '>Error code: ' & @error & @CRLF)
EndIf
Next
    Next
EndFunc

 

Link to comment
Share on other sites

please help me

#include <File.au3>
#include <Array.au3>
#include <Inet.au3>
#include <String.au3>

Global $readlist = FileRead(@ScriptDir & "\sitelist.txt")

_firstdownloaded()

Func _firstdownloaded()
    Local $olddir = @ScriptDir & '\old\'
    Local $sitelisturl = StringSplit(StringStripCR($readlist), @LF)
        For $i = 1 To UBound($sitelisturl) - 1
            $sitenamestr = StringRegExp($sitelisturl[$i], 'https?://(?:www.)?([^.]+)', 3)
            $sitenames = $sitenamestr[0]
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sitenames = ' & $sitenames & @CRLF & '>Error code: ' & @error & @CRLF)
            $downloadtemp = @ScriptDir & '\old\' & $sitenames & '.xml'
            If FileExists(@ScriptDir & "\old" & $downloadtemp) Then
                $inetgetsites = InetGet($sitelisturl[$i], $downloadtemp, 1, 1)
            Else
                DirCreate(@ScriptDir & "\" & "old")
                $inetgetsites = InetGet($sitelisturl[$i], $downloadtemp, 1, 1)
            EndIf
$ext = $sitenames & '.xml'
$array = _FileListToArray($olddir, $ext, $FLTA_FILES)
For $i = 1 To $array[0]
    $openFile = FileOpen($olddir & $array[$i], 1)
    $sFileRead = FileRead($openFile)
    If StringInStr($sFileRead, "<!--") Then
    $htmlcommentDelete = StringRegExpReplace($sFileRead[$i], '(?s)<!--.*?-->', "")
    $newerLine = StringLen($htmlcommentDelete)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $newerLine = ' & $newerLine & @CRLF & '>Error code: ' & @error & @CRLF)
    FileClose($openFile[$i])
EndIf
Next
    Next
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...