vb6 Capture Entire Web Page

南笙酒味 提交于 2019-12-08 13:09:28

问题


Hey all, I've been trying to find the code that allowed me to capture an entire web page using the webbrowser1 control and i believe also a picturebox or 2.. but i am not able to find the code that i used a couple months ago! I've been goodgling until I'm all googled out!

If anyone knows of the code for VB6 then please post a link to it!.

Thanks,

David


回答1:


Do you mean the HTML source? If so you can add a reference to the Microsoft HTML obj Library and;

Dim doc As MSHTML.HTMLDocument
set doc = YourWebBrowserCtrl.Document
msgbox doc.documentElement.outerHTML

However this will not return the exact source as at this point its been parsed by IE. (It also won't include doc type or anything else preceding the opening <html> tag.

If you do want the source, add an internet transfer control and just call .openURL to get the full content.




回答2:


    Dim DrawSize As New Size(1024, 768)
    Using MyBrowser As New WebBrowser
        MyBrowser.ScrollBarsEnabled = False
        MyBrowser.Size = DrawSize
        MyBrowser.Navigate("http://www.stackoverflow.com")
        While MyBrowser.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While
        Using myBitmap As New Bitmap(DrawSize.Width, DrawSize.Height)
            MyBrowser.DrawToBitmap(myBitmap, New Rectangle(New Point(0, 0), DrawSize))
            myBitmap.Save("C:\test.jpeg")
        End Using
    End Using


来源:https://stackoverflow.com/questions/3433259/vb6-capture-entire-web-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!