Jump to content

Need help with pulling specific data in a table on a website.


Go to solution Solved by dar100111,

Recommended Posts

Hey All,
 
I'm creating a script that is tracking reference numbers on a website.  The information when tracked comes back in an array.  It's pulling the references from an Excel sheet already and I want to be able to pull certain columns from the table and enter into the field.  I created a loop that is working fine right now and just having a hard time to figure out how to select a certain column in a certain row.  See my example for the estimated available field below
 
Would I write the table to an array?  And how would I be able to determine the column or location in the array so that I could write it back to my excel document?

I've got everything working fine except for this part.
 
Sorry I'm pretty new to programming in general so thanks for the help!
 

table screen shot.docx

Edited by dar100111
Link to comment
Share on other sites

  • Moderators

Hi, dar100111. Can you give an example of what the table would look like? It would be easier to assist in pulling the specific index if we can see the number of rows and columns.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

do you want to extract a table from a web page and copy it's content into an array?, if so, you can use IE.au3 in this way:

#include <IE.au3>
#include <Array.au3>
$sUrl = "http://free-tv.ie/astra-satellite-frequencies" ; example url
$oIE = _IECreate($sUrl) ; Create an Internet Explorer Browser Window
_IELoadWait($oIE) ; Wait for a browser page load to complete before returning
$oTable = _IETableGetCollection($oIE, 0) ; 0 = select first table on page.
$aTableData = _IETableWriteToArray($oTable, True) ; Reads the contents of a Table into an array
 _ArrayDisplay($aTableData)

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

two ways, dynamically loop through the array for the header information you need, and then use that reference to get the data...or, if that table is static, define it.

;dynamic
$sTableDataToLookFor = "title_of_header"
$iTableDataToLookFor = -1
For $i = 0 To UBound($aTable,2) - 1
    If $aTable[0][$i] = $sTableDataToLookFor Then
        $iTableDataToLookFor = $i
        ExitLoop
    EndIf       
Next

If $iTableDataToLookFor < 0 Then
    MsgBox(1,1,"couldn't find data point to search for in the array")
Else
    MsgBox(1,1,"data=" & $aTable[1][$iTableDataToLookFor])  
EndIf

;fixed:
$iTableDataToLookFor = 3
MsgBox(1,1,"data=" & $aTable[1][$iTableDataToLookFor])
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

I really appreciate all the help so far.  I'm this much closer.  So i found the correcty array but I would think there still has to be an index of some sort that I can save to my variable to input back into excel.  The table looks like this below with the brackets seperating the columns.  This is the arraydisplay that I copied from my clipboard and pasted.

If I wanted to pull the pieces and save it to a variable.  I still can't figure out how to read Row 1, Column 4, which is the "3" represented; to the right of "SAN" below.

Is there a function that does that from an array?

[0]|Reference Number|Current Status|Origin|Dest|Pieces|Weight|Last Handled|POD Information|Estimated Available (L)|Estimated Charges|Docs
[1]|43558693|Arrived At Destination|ORD|SAN|3|3509.0 L |SAN|Signed By: -Date: -|05/17/2013 13:00 |$998.25|0
 

Link to comment
Share on other sites

I'd like to dispute that best answer :P...especially since I have that exact method defined in pst #6...the 'fixed' route

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Moderators

To show your appreciation for all the help, you may want to select someone else's post as the best answer - rather than your own.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...