Jump to content
Sign in to follow this  
Aeterna

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

Recommended Posts

Aeterna

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
herewasplato

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
Aeterna

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
Authenticity

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.