Help sought with textbetween and wildcards / whitespace trim?

If you made a script you can offer it to the others here, or ask help to improve it. You can also report here bugs & problems with existing scripts.
Post Reply
daws0n
Posts: 53
Joined: 2005-02-04 13:53:18

Help sought with textbetween and wildcards / whitespace trim?

Post 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!
antp
Site Admin
Posts: 9651
Joined: 2002-05-30 10:13:07
Location: Brussels
Contact:

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

Post 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.
Post Reply