Hi everyone. I'm trying to use VB script to load a table from a HTML page to a text file. The problem is that the webpage has a EULA agreement prompt which i need to get past in order to download the table. I get an error message about button sometimes but at times the button is being clicked, although IE.document.body is non-existent and nothing gets written to the file.
Do any of you know how I can click the button that appears but at the same time be able to access the document body of the page I get to.
Thanks Paul
Dim strContents Dim row Dim Tables, Table Dim IE, IE2, IE3 Dim TableData, Td, Tr, Trs Dim Data, Data1 Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True IE.Navigate ("https://www.noridianmedicare.com/p-medb/enroll/ optout/oregon_optout.html") Do While IE.Busy Loop wscript.sleep(100)
Set Tables = IE.document.Body.getElementsbyTagName("table")
Set myFSO = CreateObject("Scripting.FileSystemObject") Set WriteStuff = myFSO.OpenTextFile("\\db1\production\Files \MedicareOptoutProviderList\medicareoptout.txt", 2, True)
For Each Table In Tables Set TableData = Tables.Item(0) Set Trs = TableData.getElementsbyTagName("tr") For Each Tr In Trs Set Data = Tr.getElementsbyTagName("td") For Each Td In Data row = row & Td.innertext & vbTab Next row = Replace(row, vbCrLf, strContents) WriteStuff.WriteLine(row) row = "" Next Next WriteStuff.Close IE.Quit
> Hi everyone. I'm trying to use VB script to load a table from a HTML > page to a text file. The problem is that the webpage has a EULA > agreement prompt which i need to get past in order to download the > table. I get an error message about button sometimes but at times the > button is being clicked, although IE.document.body is non-existent and > nothing gets written to the file.
> Do any of you know how I can click the button that appears but at the > same time be able to access the document body of the page I get to.
> Thanks > Paul
> Dim strContents > Dim row > Dim Tables, Table > Dim IE, IE2, IE3 > Dim TableData, Td, Tr, Trs > Dim Data, Data1 > Set IE = CreateObject("InternetExplorer.Application") > IE.Visible = True > IE.Navigate ("https://www.noridianmedicare.com/p-medb/enroll/ > optout/oregon_optout.html") > Do While IE.Busy > Loop > wscript.sleep(100)
> Set Tables = IE.document.Body.getElementsbyTagName("table")
> Set myFSO = CreateObject("Scripting.FileSystemObject") > Set WriteStuff = myFSO.OpenTextFile("\\db1\production\Files > \MedicareOptoutProviderList\medicareoptout.txt", 2, True)
> For Each Table In Tables > Set TableData = Tables.Item(0) > Set Trs = TableData.getElementsbyTagName("tr") > For Each Tr In Trs > Set Data = Tr.getElementsbyTagName("td") > For Each Td In Data > row = row & Td.innertext & vbTab > Next > row = Replace(row, vbCrLf, strContents) > WriteStuff.WriteLine(row) > row = "" > Next > Next > WriteStuff.Close > IE.Quit
If you open the three web pages below in the shown order then you should be able to access your table:
> > Hi everyone. I'm trying to use VB script to load a table from a HTML > > page to a text file. The problem is that the webpage has a EULA > > agreement prompt which i need to get past in order to download the > > table. I get an error message about button sometimes but at times the > > button is being clicked, although IE.document.body is non-existent and > > nothing gets written to the file.
> > Do any of you know how I can click the button that appears but at the > > same time be able to access the document body of the page I get to.
> > Thanks > > Paul
> > Dim strContents > > Dim row > > Dim Tables, Table > > Dim IE, IE2, IE3 > > Dim TableData, Td, Tr, Trs > > Dim Data, Data1 > > Set IE = CreateObject("InternetExplorer.Application") > > IE.Visible = True > > IE.Navigate ("https://www.noridianmedicare.com/p-medb/enroll/ > > optout/oregon_optout.html") > > Do While IE.Busy > > Loop > > wscript.sleep(100)
> > Set Tables = IE.document.Body.getElementsbyTagName("table")
> > Set myFSO = CreateObject("Scripting.FileSystemObject") > > Set WriteStuff = myFSO.OpenTextFile("\\db1\production\Files > > \MedicareOptoutProviderList\medicareoptout.txt", 2, True)
> > For Each Table In Tables > > Set TableData = Tables.Item(0) > > Set Trs = TableData.getElementsbyTagName("tr") > > For Each Tr In Trs > > Set Data = Tr.getElementsbyTagName("td") > > For Each Td In Data > > row = row & Td.innertext & vbTab > > Next > > row = Replace(row, vbCrLf, strContents) > > WriteStuff.WriteLine(row) > > row = "" > > Next > > Next > > WriteStuff.Close > > IE.Quit
> If you open the three web pages below in the shown order then you should be > able to access your table:
> > > Hi everyone. I'm trying to use VB script to load a table from a HTML > > > page to a text file. The problem is that the webpage has a EULA > > > agreement prompt which i need to get past in order to download the > > > table. I get an error message about button sometimes but at times the > > > button is being clicked, although IE.document.body is non-existent and > > > nothing gets written to the file.
> > > Do any of you know how I can click the button that appears but at the > > > same time be able to access the document body of the page I get to.
> > > Thanks > > > Paul
> > > Dim strContents > > > Dim row > > > Dim Tables, Table > > > Dim IE, IE2, IE3 > > > Dim TableData, Td, Tr, Trs > > > Dim Data, Data1 > > > Set IE = CreateObject("InternetExplorer.Application") > > > IE.Visible = True > > > IE.Navigate ("https://www.noridianmedicare.com/p-medb/enroll/ > > > optout/oregon_optout.html") > > > Do While IE.Busy > > > Loop > > > wscript.sleep(100)
> Set Tables = IE.document.Body.getElementsbyTagName("table")- Hide quoted text -
> - Show quoted text -
I found the problem. I had to use the url of the I Agree button, the url that appears at the bottom of the browser window when the mouse is over the button.
> > > Hi everyone. I'm trying to use VB script to load a table from a HTML > > > page to a text file. The problem is that the webpage has a EULA > > > agreement prompt which i need to get past in order to download the > > > table. I get an error message about button sometimes but at times the > > > button is being clicked, although IE.document.body is non-existent and > > > nothing gets written to the file.
> > > Do any of you know how I can click the button that appears but at the > > > same time be able to access the document body of the page I get to.
> > > Thanks > > > Paul
> > > Dim strContents > > > Dim row > > > Dim Tables, Table > > > Dim IE, IE2, IE3 > > > Dim TableData, Td, Tr, Trs > > > Dim Data, Data1 > > > Set IE = CreateObject("InternetExplorer.Application") > > > IE.Visible = True > > > IE.Navigate ("https://www.noridianmedicare.com/p-medb/enroll/ > > > optout/oregon_optout.html") > > > Do While IE.Busy > > > Loop > > > wscript.sleep(100)
> Set Tables = IE.document.Body.getElementsbyTagName("table")- Hide quoted > text -
> - Show quoted text -
I found the problem. I had to use the url of the I Agree button, the url that appears at the bottom of the browser window when the mouse is over the button.