Sign in to follow this  
Followers 0
Aeterna

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

4 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Change 2 to 3 in the last parameter of StringRegExp, and read the help file please.

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  
Followers 0