Jump to content
Sign in to follow this  
topsyleeus

Read <tr> element and write to a file

Recommended Posts

topsyleeus

Hi,

I have a HTML fime like this -

</SCRIPT>

<TABLE class=report width=100%>

<TR><TD>

</TD></TR>

<TR><TD>

<span style="font-family:Arial">

<TABLE class=report border="0" width="100%">

<tr>

<td width="50%"><H1 class=report>Change Summary</H1></td>

<td><p align="right"><b>As Of: </b>

03/14/2012

2:35:52 am

</td>

</tr>

</TABLE>

<p>

<p>

<TABLE class=report border="0" width="100%" cellpadding="0">

<tr>

<td width="10%"><b>Change#</b></td>

<td width="25%"><b>Status / Category</b></td>

<td width="25%"><b>Open Date</b></td>

<td width="30%"><b>Affected Contact</b></td>

<td width="10%"><b>Priority</b></td>

</tr>

</TABLE>

<TABLE class=report border="0" width="100%" cellpadding="0">

<tr>

<td width="10%" valign="top">40296

</td>

<td width="25%" valign="top">Completed

</td>

<td width="25%" valign="top">2/02/2012 9:17:13 am

</td>

<td width="30%" valign="top">&nbsp;

</td>

<td width="10%" valign="top">3 - Med

</td>

</tr>

<tr>

<td width="10%"></td>

<td width="25%" valign="top">&nbsp;

</td>

<td colspan="3"><b>Summary: </b>&nbsp; </td>

</tr>

</TABLE>

<hr>

<TABLE class=report border="0" width="100%" cellpadding="0">

<tr>

<td width="10%" valign="top">40238

</td>

<td width="25%" valign="top">Completed

</td>

<td width="25%" valign="top">1/30/2012 12:02:15 pm

</td>

<td width="30%" valign="top">&nbsp;

</td>

<td width="10%" valign="top">3 - Med

</td>

</tr>

<tr>

<td width="10%"></td>

<td width="25%" valign="top">&nbsp;

</td>

<td colspan="3"><b>Summary: </b>&nbsp; </td>

</tr>

</TABLE>

<hr>

<TABLE class=report border="0" width="100%" cellpadding="0">

<tr>

<td width="10%" valign="top">40226

</td>

<td width="25%" valign="top">Completed

</td>

<td width="25%" valign="top">1/27/2012 2:53:26 pm

</td>

<td width="30%" valign="top">&nbsp; </td>

<td width="10%" valign="top">3 - Med

</td>

....and so on

I want to read the 1st column's five digit numbers for every table.

Like the file should contain data like -

40296

40238

40226

............

How do I achieve that?

Edited by topsyleeus

Share this post


Link to post
Share on other sites
UEZ

Try this:

#include <Array.au3>
$sHTML = FileRead(@ScriptDir & "Test.html")
$aChangeNo = StringRegExp($sHTML, 'valign="top">(d+).rn', 3)
_ArrayDisplay($aChangeNo)

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
topsyleeus

Thank you both..Here goes the working code

#include <IE.au3>

#include <Array.au3>

Local $oIE =_IEAttach("Title of the page")

Local $oFrames = _IEFrameGetCollection($oIE)

Local $iNumFrames = @extended

Local $oFrame = _IEFrameGetCollection($oIE, $iNumFrames-1)

MsgBox(0, "Frame Info", _IEPropertyGet($oFrame, "locationurl"))

local $reportFrame = _IEBodyReadHTML($oFrame)

MsgBox(0, "Frame Info", $reportFrame)

$oTable = _IETableGetCollection($oFrame)

Local $iNumTables = @extended

MsgBox(0, "test", $iNumTables)

for $i = 4 To $iNumTables-1

Local $oTables = _IETableGetCollection($oFrame,$i)

Local $aTableData = _IETableWriteToArray($oTables,True)

$coNumbers = $aTableData[0][0]

MsgBox(0, "Test", $coNumbers)

Next

Edited by topsyleeus

Share this post


Link to post
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
Sign in to follow this  

×