Page 1 of 1

Help sought with textbetween and wildcards / whitespace trim?

Posted: 2024-05-29 20:01:30
by daws0n
I am attempting to work on a script to parse details from HTML pages using "textbetween" variables.

E.g, if I want to scrape the following for value "84"

Code: Select all

<button slot="Score" data-Manager="overlayOpen:click" theme="transparent">
            <theme="medium">84%</info>
The script below works, but I am having to lay out a lot of HTML and white space to scrape the data that I am looking for.

Code: Select all

value := textbetween(page, '<button slot="Score" data-Manager="overlayOpen:click" theme="transparent">'+ #13#10 +'            <theme="medium">' , '%<');

For simplicity is it posssible to tell AMC to trim out white space / line breaks beforehand? Alternatively, could I use wildcards instead of complete strings?

E.g something like

Code: Select all

value := textbetween(page, '<button slot="Score" [*anything*] theme="medium">' , '%<');
Thank you!

Re: Help sought with textbetween and wildcards / whitespace trim?

Posted: 2024-06-01 13:42:04
by antp
If you want to completely remove HTML tags and just keep the text in-between, you can also use the HTMLRemoveTags procedure. That one modifies the variable that you pass rather than returning a modified version of the text.
Then you can call the Trim function if there are useless spaces and linebreaks around the text.