Problem Description:
I am attempting to manipulate a webpage using the {urlload} command in Text Blaze. I successfully constructed the required URL dynamically by splitting it into two parts: link01 (fixed) and link02 (dynamic, obtained via regex). The full URL is formed correctly, but when I use this concatenated variable directly in {urlload}, it fails to load. However, if I copy the generated URL value and manually paste it into {urlload}, the command works perfectly. I need assistance in resolving this issue.
Implementation Details:
Part 01 (OK):
Extracting the HTML code where the link is located:
{site: html; page=https://example.com/*; selector=#poloPassivo > table > tbody > tr > td > a; multiple=no}
Part 02 (OK):
Extracting the link02 variable using regex:
{link02={=replace(concat("https://example.com", {=extractregex({site: html; page=https://example.com/*; selector=#poloPassivo > table > tbody > tr > td > a; multiple=no}, "href="([^"]+)"")}), "&", "&")}}
Part 03 (OK):
Defining the link01 variable:
{link01="https://example.com"}
Part 04 (OK):
Constructing the complete URL:
{link={=link01 & link02}}
{=link}
Part 05 (FAIL):
Using the link variable in {urlload}:
{urlload: {=link}; done=(contents, status) -> [ "status": status, "pageContents": contents ]}
Issue:
The {urlload} command fails when using the link variable.
However, copying the generated value of {=link} and pasting it manually into the {urlload} command works as expected.
Goal:
I need the {urlload} command to work directly with the link variable without requiring manual intervention.
1 Like
Hello Felipe,
The urlload
command needs to have a fixed domain, this is necessary to connect the snippet to that domain and ensure security. This means the entire URL can't be dynamic.
For example, you can have the path of the URL dynamic while the domain remains static:
{path="api/temperature"} {urlload: https://blaze.today/{=path}; done=(res) -> ["temperature": catch(fromJSON(res).temperature, "???")]}
The temperature is currently {=temperature}°
If your link1
is always the same, this should solve your issue, you can change your code to be:
{urlload: https://example.com{=link02}; done=(contents, status) -> [ "status": status, "pageContents": contents ]}
If instead it changes, but its limited to a number of possible domains, you could have a condition that runs the adequate {urlload} depending on which site you it needs.
Help me, Parlapiano. If I understand this, I will take my Text Blaze usability to the next level.
The site is connected to the domain.
The first part is static!
The second part is dynamic.
Pasting the result into the browser works, which shows that link3 is correct.
Pasting the result into the {urlload} formula also works, but it does not work directly.
PART 1
Static Part (OK):
{link01="https://my.site.com"}
PART 2.1
Dynamic Part Obtained via Regex (OK):
{link02={=replace({=extractregex({site: html; page=https://my.site.com/*; selector=#poloPassivo > table > tbody > tr > td > a; multiple=no}, "href="([^"]+)"")}, "&", "&")}}
PART 3
Combining the Static and Dynamic Parts:
{link3={=link01&link02}}
PART 4 (Error):
Fails when using the combined variable directly:
{urlload: {=link03}; done=(contents, status) -> [ "status": status, "pageContents": contents ]}
{=pageContents}
Error: {urlload} URL must have a fixed domain like "https://example.com".
PART 5 (OK):
Works when copying and pasting the result of {=link3} manually:
{urlload: "https://my.site.com/variable"; done=(contents, status) -> [ "status": status, "pageContents": contents ]}
{=pageContents}
Issue:
The {urlload} command does not work when using the dynamically constructed {=link03} variable. However, manually pasting the generated URL into {urlload} works as expected.
How can I make {urlload} work directly with the combined variable?
Could you try updating your {urlload}
to the following? Make sure to update https://my.site.com
to your correct site inside the urlload command:
{urlload: https://my.site.com{=link02}; done=(contents, status) -> [ "status": status, "pageContents": contents ]}
Your example is not working because you're passing {=link03}
as a single value, and since link03
is a variable, the entire value is dynamic. For urlload
to work, the domain must be a string.
Note that in the example I give above, the domain is a string, followed by the link02
.
If the above doesn't work, I'd be happy to jump on a call with you. You can email me at obed@blaze.today
1 Like
The domain must be connected in Text Blaze.
The command in Text Blaze is correct!
{urlload: https://my.site.com/{=link}; done=(contents, status) -> [ "status": status, "pageContents": contents ]}
The only observation is: if the variable link starts with a "/", disregard it, as it is part of the fixed link.
Now I no longer need to open multiple browser tabs for Text Blaze to find the reference. It fetches it automatically (urlload + regex)—truly PHENOMENAL.
Thank you so much, Obed Parlapiano!
1 Like