You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m trying to extract data from a JS variable from page that has a structure like this:
<!DOCTYPE html><html><head>
...
</head><body><divid="main">
...
</div><script>varconfig={"test": "one"};varPageData={"someVariable": [{// data}];};</script><script>// some other script</script></body></html>
My goal is to monitor changes to the contents of PageData.someVariable (actually even deeper than that, as is quite a complex object).
So far, I used the Extract text feature with the following regex: /.*?var\s+PageData\s*=\s*({[\s\S]*?});/i
This successfully captures the object assigned to PageData. However, I’m unable to use the CSS/JSONPath/JQ/XPath Filters box to drill into the data (e.g., $.someVariable)—I’m guessing that’s because the JSONPath filter is run before the extract step?
Has anyone successfully extracted and navigated JS variables like this?
I’d love any help or workarounds—do I need to reformat the extract or is there a better way to approach this?
I guess I could "simply" use the "Extract text" functionality on the actual object variable I'm after (e.g. /\{[^{}]*object_property[^{}]*\}/), but that still doesn't allow me to parse it as json...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m trying to extract data from a JS variable from page that has a structure like this:
My goal is to monitor changes to the contents of PageData.someVariable (actually even deeper than that, as is quite a complex object).
So far, I used the Extract text feature with the following regex:
/.*?var\s+PageData\s*=\s*({[\s\S]*?});/i
This successfully captures the object assigned to PageData. However, I’m unable to use the CSS/JSONPath/JQ/XPath Filters box to drill into the data (e.g., $.someVariable)—I’m guessing that’s because the JSONPath filter is run before the extract step?
Has anyone successfully extracted and navigated JS variables like this?
I’d love any help or workarounds—do I need to reformat the extract or is there a better way to approach this?
I guess I could "simply" use the "Extract text" functionality on the actual object variable I'm after (e.g.
/\{[^{}]*object_property[^{}]*\}/
), but that still doesn't allow me to parse it as json...Thanks in advance 🙏
Beta Was this translation helpful? Give feedback.
All reactions