1

Im working in a puppeteer js scrapping project that is running in Windows terminal "node file.js". I get an array as my scrapping result, but now I need to use it in php. I need to make a file for php to read or to send the data directly to my php file.

Any ideas?

I have tried AJAX but I get this: ReferenceError: XMLHttpRequest is not defined

Also I have tried to create the file in my js project using:

new File([provincias], "xScrap.json", { type: "application/json" });

and getting this result: ReferenceError: File is not defined

0

1 Answer 1

0

For why there is an error of ReferenceError: XMLHttpRequest it is for web browsers, and node js has another way of creating HTTP requests: XMLHttpRequest module not defined/found

To send or request data to your PHP file or server, you need to create HTTP requests. I personally suggest using Axios, but there are a lot of alternatives here: How is an HTTP POST request made in node.js?

As for your creation of file error, I don't know why it isn't working, but I'll suggest using the fs module to create/read/update/delete files in node js: https://blog.risingstack.com/fs-module-in-node-js/

Sign up to request clarification or add additional context in comments.

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.