0

Let's say, when we open link https://example.com and that page generates javascript variable, called xyz, so we can access it from browser's Inspect console:

console.log(xyz);

However, how can we get & read that variable from node.js ? (the external link needs to be rendered like in browser, to get javascript values out of it).

1
  • There is 10 years old topic on SO, but I doubt it is applicable now and there should have changed many things in the meantime. Commented Feb 21, 2021 at 16:13

2 Answers 2

1

There are different approaches to get the variable, depending how they are created.

  • variable is directly in source code so you can simply parse it using regEx for example.
  • variable is being evaluated in JS runtime, in this case you need to mock the browser environment using PhantomJS, which is quite heavy.
Sign up to request clarification or add additional context in comments.

1 Comment

yes, i have been talking about runtime evaluation. so, PhantomJS or Nightwatch seems possible route..
0

One possible way seems to use plugin like Nightwatch. However, in the past it depended selenium, which is a bit heavy.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.