برگزیده های پرشین تولز

ذخیره کردن frame توی htmldocument

hellbound

کاربر تازه وارد
تاریخ عضویت
25 ژوئن 2005
نوشته‌ها
181
لایک‌ها
0
hi guys
I'm trying to save an html file into local path, but I have trouble with saving frames, below is my current code for this part.

thanks
سلام.
من دارم یه فایل HTML رو روی هارد دیسک ذخیره می کنم ، که با ذخیرۀ فریم مشکل دارم. کدی که تا الان نوشتم این زیره.
ممنون.



کد:
Dim objImg As IHTMLImgElement               'object holder for html images
Dim objHypLink As MSHTML.HTMLLinkElement    'object holder for html hyperlink
Dim objMSHTML As New MSHTML.HTMLDocument    'main html creator using CreateDocument
Dim objDoc As HTMLDocument                  'main holder for html document
Dim vFileName, vPath                        'temporary filename for images and html to download and send /
                                            'filepath holder for eath file
Dim objFrm As IHTMLElementCollection        'object holder for frames inside html document
Dim defPath 'Default Path                   'default saving path

Dim vTemp                                   'temporary holder for status message
defPath = "C:\Temp\"

'load page
Set objDoc = objMSHTML.createDocumentFromUrl(txtAddress, vbNullString)

'wait for loading

AddStat "Start Loading webpage..."
Do While objDoc.ReadyState <> "complete"
    If vTemp <> objDoc.ReadyState Then
        AddStat objDoc.ReadyState
    End If
    vTemp = objDoc.ReadyState
    DoEvents
Loop
AddStat "Loading completed."

Dim vFile(), I  'html filenames and paths

'insert frame to main html
MsgBox objDoc.frames.length
ReDim vFile(0 To objDoc.frames.length + objDoc.images.length)
For I = 0 To objDoc.frames.length - 1
    Dim eCollection As IHTMLElementCollection
    Set eCollection = objDoc.frames(I).Document.All
    MsgBox objDoc.frames(I).Document.All
    vFile(I) = defPath & Replace(Mid(objFrm.src, Len(objDoc.location) + 1), "/", "\")
    vPath = Mid(vFile(I), InStrRev(vFile(I), "\") + 1)
    rMkDir Mid(vFile(I), 1, InStrRev(vFile(I), "\"))
    URLDownloadToFile 0&, objFrm.src, vFile(I), 0&, 0&
Next I
 
بالا