Check whether the text in a webpage contains the keyword or keywords from an array, then using the if condition


Good morning,

May I ask how to check whether the text in a webpage (for example, the text from the webpage that shown in attached figure) contains the keyword or keywords from an array {abc, def, ghi, …}.
Then using the if condition with that results.

Thank you and best regards.

1 Like

What have you currently done so far?

You could try a for each loop and loop through the array.

e.g.
For each - item in array
If webpagetext.contains(item) = true
"Yes / “No”

Something like this? If your goal is to loop through, find a match and then do something with the match then it should work fine.

1 Like

Thank you @CBlanchard for your reply, may I ask what is the easier way to create an array in UiPath? Don’t want read from excel one.

Thank you and best regard.

@teo_choudu

First read entire text and assign it to one string variable. And then split this text based on space as delimiter and will give you output as array of string.

      textArray [] = webText.Split(" "c)

And then compare this array with your keywords array to check whether any matching words are there or not.

Oh you haven’t even got an array? Have you used UiPath much before? You might be better off utilising the academy to learn how to use UiPath.

If you’ve got all the keywords you’re looking for in an excel spreadsheet or CSV, you could simply create a datatable and use for each row instead of for each.

I had solved my keywords input by using excel file.

Can I ask that do I need to get text from the webpage first?

Thank you.

Yep - you will need to use screen scraping to get the text off the webpage and save it in a string variable

After screen scraping the text off the webpage, how to fill the If activity’s condition expression? Is it “If webpagetext.contains(item) = true”?

Thank you very much.

@lakshman

Hi, may I know how to read entire text and assign it to one string variable? Is it by using screen scraping?

@teo_choudu

Yes you can use Screen scraping and also Get Text activity also.