gcue

building a reference array from html

8 posts in this topic

hello world =)

i am trying to create an array from lines that look like this..

<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters='{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"40245"}'>AFS</a></strong></td>

<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters='{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"39019"}'>JLKF</a></strong></td>

to an array that looks like this.. 

$array[0][0] = AFS 

$array[0][1] = 40245 

$array[1][0] = JLKF

$array[1][1] = 39019

the html source code is huge (over 30,000 lines) but these lines are unique as they all start with 

<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters='{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"

and end with

</a></strong></td>

many thanks in advance! 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How about _IETableWriteToArray? If necessary remove the unneeded part from the returned data.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

unfortunately, the IDs are only in the source code.

Share this post


Link to post
Share on other sites

Something like this:

#include <Array.au3>
Global $sLine = '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"40245"}''>AFS</a></strong></td>'
If StringLeft($sLine, 148) = '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"' Then
    $sString = StringMid($sLine, 149)
    $aStrings = StringSplit($sString, ">")
    _ArrayDisplay($aStrings)
    $aStrings = StringSplit($aStrings[2], "<")
    ConsoleWrite($aStrings[1] & @CRLF)
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

unfortunately, the IDs are only in the source code.

?? do you mean "ContentControlListId"

?? Do you need 1D or 2D array ?

 

Edit:

is it sufficient:

Local $sHTML_content = _IEDocReadHTML($oIE)
Local $aContent = StringRegExp($sHTML_content,'ContentControlListId":"(\d+)"}''>(.*?)<',3)

??

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Maybe this.

#include <Array.au3>

Global $sLine = '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''' & _
        '{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"40245"}''>AFS</a></strong></td>' & _
        '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''' & _
        '{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"39019"}''>JLKF</a></strong></td>'

local $sStart = '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''' & _
        '{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"'
local $sEnd = '</a></strong></td>'

local $aArray1D = StringRegExp($sLine, $sStart & '(\d+)"}''>([^>]+)' & $sEnd, 3)
;_ArrayDisplay($aArray1D)

Local $aArray2D[UBound($aArray1D) / 2][2], $sDisplay

For $i = 0 To UBound($aArray2D) - 1
    $aArray2D[$i][0] = $aArray1D[2 * $i + 1]
    $aArray2D[$i][1] = $aArray1D[2 * $i]
    $sDisplay &= "$aArray2D[" & $i & "][0] = " & $aArray2D[$i][0] & @LF & _
                 "$aArray2D[" & $i & "][1] = " & $aArray2D[$i][1] & @LF
Next
ConsoleWrite($sDisplay & @LF)
_ArrayDisplay($aArray2D)

#cs ; Returns
    $aArray2D[0][0] = AFS
    $aArray2D[0][1] = 40245
    $aArray2D[1][0] = JLKF
    $aArray2D[1][1] = 39019
#ce

 

Share this post


Link to post
Share on other sites

?? do you mean "ContentControlListId"

?? Do you need 1D or 2D array ?

 

Edit:

is it sufficient:

Local $sHTML_content = _IEDocReadHTML($oIE)
Local $aContent = StringRegExp($sHTML_content,'ContentControlListId":"(\d+)"}''>(.*?)<',3)

??

2 column array =)

i was getting some off results i think because the tail end of the line was not specified?

regardless - thanks for your help

Share this post


Link to post
Share on other sites

Maybe this.

#include <Array.au3>

Global $sLine = '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''' & _
        '{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"40245"}''>AFS</a></strong></td>' & _
        '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''' & _
        '{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"39019"}''>JLKF</a></strong></td>'

local $sStart = '<td><strong><a class="setOverlayEvent email-link-title-blue" href="#" parameters=''' & _
        '{"targetOverlayDialog":"genOverlayDialog","ContentControlListId":"'
local $sEnd = '</a></strong></td>'

local $aArray1D = StringRegExp($sLine, $sStart & '(\d+)"}''>([^>]+)' & $sEnd, 3)
;_ArrayDisplay($aArray1D)

Local $aArray2D[UBound($aArray1D) / 2][2], $sDisplay

For $i = 0 To UBound($aArray2D) - 1
    $aArray2D[$i][0] = $aArray1D[2 * $i + 1]
    $aArray2D[$i][1] = $aArray1D[2 * $i]
    $sDisplay &= "$aArray2D[" & $i & "][0] = " & $aArray2D[$i][0] & @LF & _
                 "$aArray2D[" & $i & "][1] = " & $aArray2D[$i][1] & @LF
Next
ConsoleWrite($sDisplay & @LF)
_ArrayDisplay($aArray2D)

#cs ; Returns
    $aArray2D[0][0] = AFS
    $aArray2D[0][1] = 40245
    $aArray2D[1][0] = JLKF
    $aArray2D[1][1] = 39019
#ce

 

works perfectly Malkey!

thank you SOOO much!

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