HTTrack Website Copier
Free software offline browser - FORUM
Subject: Running HTTrack from a VB.net script
Author: CB
Date: 05/31/2012 08:47
 
If anyone is looking to run httrack (command line version) from VB, here's what
I have (so far) ... seems to work well. This method is called from elsewhere
in the program, passing the URL to mirror, the output directory, and mirror
depth as arguments.
(some wrapping may need to be straightened out from pasting this ...)


Private Sub MirrorWebsite(ByVal strURL As String, ByVal strDirectoryPath As
String, ByVal intDepth As Integer)

        'create the website mirror

        Dim strHTPath As String = """C:\Program
Files\WinHTTrack\httrack.exe"""

        Dim strHTTrackMirrorURL As String = """" & strURL & """"

        'create the string of options for HTTrack

        '-O is the output path

        Dim strHTTrackOutput As String = " -O """ & strDirectoryPath & """"

        'create the list of mirroring options
        '-rN is the Nth level mirror level depth
        'these are the options I use - yours may be different ... see the
on-line documentation
        Dim strHTTrackOptions As String = " -q" & "r" & intDepth.ToString &
"%e0C2%Pxs0u1%s%uN0%Ip7DaK0c2T6J128R2H1%kf2o0A50000%c2#L10000%f#fb1j1 --assume
standard"

        Dim strHTTrackFilters As String = " +*.png +*.gif +*.jpg +*.css +*.js
-ad.doubleclick.net/*"


        'Create the new process thread to start the mirror operation
        Dim mirrorProc As New Process()
        mirrorProc.StartInfo.FileName = strHTPath
        mirrorProc.StartInfo.Arguments = strHTTrackMirrorURL &
strHTTrackOutput & strHTTrackOptions & strHTTrackFilters
        mirrorProc.StartInfo.CreateNoWindow = True
        mirrorProc.StartInfo.WindowStyle = ProcessWindowStyle.Normal
        Try
            mirrorProc.Start()
            'Wait for the thread to exit otherwise there may be a large number
of httrack processes running at the same time if you are mirroring multiple
sites

            mirrorProc.WaitForExit()
Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub


I hope this helps someone out there ... took me a while to figure it out!
 
Reply


All articles

Subject Author Date
Running HTTrack from a VB.net script

05/31/2012 08:47




5

Created with FORUM 2.0.11