0

I need to make a request with PHP to a URL:
example.com?price=99&policy=100.

I am using curl and everything worked fine so far, the problem is that the GET variables are used in the page's JavaScript code in order to send tracking analytics and other stuff. Curl doesn't execute this JavaScript code since is not a JavaScript interpreter. I am building an API, so the function that calls the URL may not be executed by a browser.

Any suggestions on what can I do?

5
  • 1
    Possible duplicate of Execute javascript in PHP Commented Sep 12, 2018 at 16:16
  • So you want to load webpage code (HTML) without browser and execute JS which is included inside? Commented Sep 12, 2018 at 16:18
  • @Tukkan Yes, basically I need to execute the Javascript code in the called url. Commented Sep 12, 2018 at 16:22
  • You may need to install a headless browser to execute client-side code or you may install node to execute it server-side Commented Sep 12, 2018 at 16:28
  • Yes, adding onto Johnny's comment, puppeteer is a good library for this - it provides an api to interact with a headless instance of chrome. Because you are using php, you will need to use puphpeteer (github.com/nesk/puphpeteer) Commented Sep 12, 2018 at 16:42

0

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.