Get data out of a webpage with VBA

前端 未结 2 1778
情话喂你
情话喂你 2021-01-27 06:46

I\'m trying to get some data out of this Webpage:

http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html

I want to have the whole table on t

相关标签:
2条回答
  • 2021-01-27 07:31

    Instead of:

    Do
        DoEvents
    
    Loop Until ie.readyState = READYSTATE_COMPLETE  
    

    You could try:

    Do While ie.Busy: DoEvents: Loop
    Do Until ie.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
    
    with ie
    ...
    end with
    
    0 讨论(0)
  • 2021-01-27 07:41

    instead of using the IE automation you can also use a http request object:

    Dim oRequest As Object
    Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
    oRequest.Open "GET", "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html"
    oRequest.Send
    MsgBox oRequest.ResponseText
    

    it's faster and doesn't need as many ressources as the solution with the IE

    if you are behind a proxy server you can use something like this:

    Const HTTPREQUEST_PROXYSETTING_PROXY = 2
    Dim oRequest As Object
    Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
    oRequest.setProxy HTTPREQUEST_PROXYSETTING_PROXY, "http://proxy.intern:8080"
    oRequest.Open "GET", "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html"
    oRequest.Send
    MsgBox oRequest.ResponseText
    

    of course you have to adjust the proxy to your values.

    As you are interessted in a german page here also a short explanation in german language: http://cboden.de/softwareentwicklung/vba/tipps-tricks/27-webseite-per-vba-ansprechen There is also explained how to pass values of a form to the webserver which might also be helpfull for you.

    0 讨论(0)
提交回复
热议问题