RickB75 Posted October 23, 2012 Posted October 23, 2012 Guys, I'm very, very new to scripting and I need a little help from the experts. I am writing a simple script to find a specific HTML tag on a webpage and Write the inner text to a excel spreadsheet. My script does this but, it keeps looping through and writes the inner text in the entire first column and keeps looping. I need it to write a cell then loop and find the next tag and write that content into a different cell and keep looping through until the end of the page. This is what I have so far. I commented out the message box, but it works pretty good. Once it grabs the inner text, it displays in a message box, I click "OK" and it loops through again and finds the next html tag and so on. include <IE.au3> #Include <Excel.au3> $oIE = _IECreate ("C:\site\changes.html") $oExcel = _ExcelBookNew() $HElements = _IETagNameGetCollection($oIE, "H2") $EMElements = _IETagNameGetCollection($oIE, "EM") For $HElement In $HElements _ExcelWriteCell($oExcel,$HElement.innerText,"A:A") ;MsgBox(0, "Element Info", "Tagname: " & $HElement.tagname & @CR & "innerText: " & $HElement.innerText) Next Any help you guys can offer is greatly appreciated!!
water Posted October 23, 2012 Posted October 23, 2012 (edited) You need a counter to define the row where you want to write the content and which is incremented for the next loop. #include <IE.au3> #Include <Excel.au3> $oIE = _IECreate ("C:sitechanges.html") $oExcel = _ExcelBookNew() $HElements = _IETagNameGetCollection($oIE, "H2") $EMElements = _IETagNameGetCollection($oIE, "EM") $iCounter = 1 For $HElement In $HElements _ExcelWriteCell($oExcel,$HElement.innerText,"A" & $iCounter) $iCounter = $iCounter + 1 Next Edited October 23, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
RickB75 Posted October 23, 2012 Author Posted October 23, 2012 Thank you for your help Water! That works perfect. You help is very much greatly appriciated!!
water Posted October 23, 2012 Posted October 23, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now