You have to login in order to post a reply to this topic.

4 replies [Last post]
codex
codex's picture
User offline. Last seen 18 weeks 18 hours ago. Offline
Joined: 11/12/2009
Posts: 161

I have included prompts to get the website address and the text to search for, but obviously you can modify the job to search in a list of URLs (that can be retrieved from a txt or an Excel file).

__________________

Error is not blindness, error is cowardice

AttachmentSize
Find Text in Web Page.waj18 KB
__________________

Error is not blindness, error is cowardice

pctone
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 12/01/2009
Posts: 3
Re: Search for text in a webpage

Dear Sir,

How can I retrieve one text string from the web page?

for example the web page string is "test string http://www.winautomation.com.......".  I want to retrieve string between "www." and ".com"

1.'Parse Text' "www." -> save to %position1%

2.'Parse Text' ".com" -> save to %position2%

3.'Set Variable' %length% = %positon2% - %position1% + 4 (But the WinAutomaition always set %length% in Text Value. So I can't using the 'Get Subtext' to retreieve string)

Could you please to check this issue? Thanks for your help.

ps: WinAutomation version is 3.0.3.410

 

Best regards,

Kevin

codex
codex's picture
User offline. Last seen 18 weeks 18 hours ago. Offline
Joined: 11/12/2009
Posts: 161
Re: Search for text in a webpage

You will have to use regular expressions in order to achieve this functionality, otherwise it gets very messy. The good thing is that you can easily create a regular expression that will grab text between 2 predefined portions of text. The basic syntax is:

(?<=TextBefore).*?(?=TextAfter)

So, in your case you will have to enter:

(?<=www\.).*?(?=\.com)

and check the "Use Regular Expressions" (or something similar) option of the "Parse Text" action.

If you want to know more about regular expressions, a very good website can be found here or you can check the dedicated forum thread here.

__________________

Error is not blindness, error is cowardice

__________________

Error is not blindness, error is cowardice

Andrew
Andrew's picture
User offline. Last seen 1 year 24 weeks ago. Offline
Joined: 03/12/2010
Posts: 33
Re: Search for text in a webpage

pctone: It looks to me like you are having the same problem I had when I first started using WinAutomation.  Step 3 should be: %length% = %position2 - position1 + 4% (note the percent signs around the entire expression) instead of how you wrote it.  If the result is an integer stored as a text variable (not sure why it would be), use the "Convert Text to Number" action.

chris-
User offline. Last seen 34 weeks 2 days ago. Offline
Joined: 05/26/2011
Posts: 3
Re: Search for text in a webpage

Thanks Codex, that helped me :)

 

Chris