Запустите скрипт Python с помощью PythonShell из Node.js
Nowadays Node.js is the most attractive technology in the field of backend development for developers around the globe. And if someone wishes to use something like Web Scraping using python modules or run some python scripts having some machine learning algorithms, then one need to know how to integrate these two.
We are going to get some data of a user through web scraping of leetcode . So, let’s get started.
Now, setup the Node.js server code first.
Now, Python Script. (Make sure you have installed the bs4 module and csv module.)
After saving both the files, run the following command from its root folder :
Now, send request through localhost:8000 in the browser.
If everything goes right, then the outout will be :
Message: csv file created for leetcode.
This is the simple implementation of a how-to run python script with Node.js which can be useful in situations where you have a stack of Node.js application and you want to run a simple python script. If you want to know moe about PythonShell module, then go through the given link.
Link : https://github.com/extrabacon/python-shell
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course