Jump to content

[SOLVED] How do I read this result?


Dent
 Share

Recommended Posts

Hi,

I've written a script to automate the logging in to a website and the generation of results as shown in Capture1.JPG

You'll see the number of results is displayed at the top, 12 in this case. What I can't work out is how to read that number into a variable.

The section of code from the site is displayed in Capture2.JPG

The only way I can think is to read the whole page with _IEBodyReadText($oIE) then use StringInStr to find it, however the result may be 1, 2 or 3 digits depending on the number of results so I'm not sure how that would be coded.

Any help greatly appreciated.

Capture1.JPG

Capture2.JPG

Edited by Dent
Marked as solved
Link to comment
Share on other sites

  • Moderators

Dent,

Read the page and then use a RegEx to extract the required elements:

#include <Array.au3>

$sText = "<p>" & @CRLF & _
"  <strong>12</strong>" & @CRLF & _
"  properties within"

$aExtract = StringRegExp($sText, "<strong>(\d+)</strong>\R\s+properties", 3)

_ArrayDisplay($aExtract, "", Default, 8)

This will get the digits regardless of number.

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba23,

Thanks for replying to my question. I've tried to implement your example as follows and inserted a ConsoleWrite too as I was getting the "Array contains no data" error and wanted to see if anything was being passed to $Results. A single '1' was passed to $Result. Here's my code, are there any obvious mistakes?

$oPage = _IEBodyReadHTML($oIE)
$Results = StringRegExp($oPage, "<strong>(\d+)</strong>\R\s+properties", 3)
ConsoleWrite($Results & @CRLF)
_ArrayDisplay($Results, "", Default, 8)

 

Link to comment
Share on other sites

  • Moderators

Dent,

Please save the page content returned by _IEBodyReadHTML as a file and let me take look - the internal structure of the HTML might well be different to the test string (I suspect the existence of @TABs rather then spaces).

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Dent,

It was indeed a format problem - this pattern works for me:

#include <Array.au3>

$sText = FileRead("M:\Downloads\Page.htm") ; You read the page directly here

$aExtract = StringRegExp($sText, "<strong>(\d+)</strong>\s+properties", 3)

_ArrayDisplay($aExtract, "", Default, 8)

M23

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

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

×
×
  • Create New...