Hello!!
I am struggling with pulling a table from a website and would greatly appreciate any help. The code I have below currently goes to the website and logs the user in using their username and password entered in cells B1 and B2. Once the code below logs the user in, there is a table immediately shown. I want to extract that table and add it to my active worksheet. I have played with codes found online without success. I have tried running queries that end up showing nothing on my worksheet and tried pulling different table numbers (without knowing which table is what) without success as well. Unfortunately the website is a paid for site and I can not share it, but I can provide some codes listed on the website for more visibility for your assistance and a screen shot. I greatly appreciate any help!!
Below is some code from the website when I hit f12 and type "table" I get this very long function that I can not really understand. Below is just a very small portion of it in hopes it might help resolve my issue. The main page when I hit12 without searching for "table" does not really show anything? It just shows what appears to be the buttons on the image shown below and does not say anything about a table or query or function. Any ideas? I am happy to provide more code to the site if any one can direct me on what to look for?
I am struggling with pulling a table from a website and would greatly appreciate any help. The code I have below currently goes to the website and logs the user in using their username and password entered in cells B1 and B2. Once the code below logs the user in, there is a table immediately shown. I want to extract that table and add it to my active worksheet. I have played with codes found online without success. I have tried running queries that end up showing nothing on my worksheet and tried pulling different table numbers (without knowing which table is what) without success as well. Unfortunately the website is a paid for site and I can not share it, but I can provide some codes listed on the website for more visibility for your assistance and a screen shot. I greatly appreciate any help!!
VBA Code:
Sub login()
Dim tb As Object, tr As Object, th As Object
Dim yourValue As String, obj As Object
Dim URL As String, IE As Object, HWNDSrc As Long
Dim currenturl As String
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Worksheets("practice report")
Set IE = CreateObject("InternetExplorer.application")
IE.AddressBar = 0
IE.StatusBar = 0
IE.Toolbar = 0
IE.Visible = True
IE.navigate "https://www.services.com/login"
' i have adjusted the above website, this is not the correct site but changed it for privacy reasons
Do Until Not IE.Busy: DoEvents: Loop
Set Doc = IE.document
Do While Doc.readyState <> "complete": DoEvents: Loop
' the below will check if you are already logged into the site. If so, it will skip the log in part
currenturl = IE.LocationURL
If currenturl = "https://www.services.com/login" Then
IE.document.all("login").Value = ws.Range("B1").Value
IE.document.all("password").Value = ws.Range("B2").Value
IE.document.all("submit").Click
Else
End If
' this is where i would like to pull the table of data into this active worksheet
End Sub
Below is some code from the website when I hit f12 and type "table" I get this very long function that I can not really understand. Below is just a very small portion of it in hopes it might help resolve my issue. The main page when I hit12 without searching for "table" does not really show anything? It just shows what appears to be the buttons on the image shown below and does not say anything about a table or query or function. Any ideas? I am happy to provide more code to the site if any one can direct me on what to look for?
JavaScript:
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="2.2.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for