Jump to content

[Help?]Count the number of time a string appears on a webpage.


Recommended Posts

Hey you brilliant people out there!

I'm trying to figure out how to count the number of times a string appears on a webpage.

Here's my stab at it:

CODE

$s_String = "blahblah"

$o_Body = _IEBodyReadHTML($oIE)

$a_array = StringRegExp($o_Body, $s_String, 2)

I tried returning that array in various ways but there didn't seem to be a method for just counting the indices of the array.

Any help would be greatly appreciated!

Link to comment
Share on other sites

UBound($a_array)

edit:

Return Value

Success: Returns the size of the array dimension.

Failure: Returns 0 and sets @error:

1 = Array given is not an array.

2 = Array dimension is invalid.

Remarks

Remember that the value returned by UBound is one greater than the index of an array's last element!

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Thanks, now I have a follow up question because that msg box wasn't giving me the answer I was expecting.

My question is.... what could be going wrong?

CODE

$oIE = _IECreate()

_IENavigate($oIE, $s_URL)

$s_String = "action=ma"

$o_Body = _IEBodyReadHTML($oIE)

$a_array = StringRegExp($o_Body, $s_String, 2)

MsgBox(0, "finds", UBound($a_array))

There are 65 links on the page that have the string "action=ma" in them. But I'm getting a "1" in the MsgBox.

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...