[ad_1]
[ad_2]
Heya!
I'm working on a project with a friend, and we need to run some Python code on a WordPress site. My friend has handled the Python part, but we're a bit lacking on the front end (I've mostly built blogs and similar sites on WordPress).
Basically, we need a functionality where users can paste website links into the site, and then the site will output something from the source code—so it's essentially a web crawler service.
Any ideas on how to make this work?
Thanks in advance!
Are you tried it from github?
You can technically create a rest API maybe using FastAPI in python (that works as a job queue because web crawlers can take some time) on another server separate from your WordPress site. Then, You can make use of rest API to communicate with your web crawlers.
I run a complex scrape from a windows box and beatify the data and then post to site and it’s just starts running from one bat file. I added press any key before it posts to the api just for QA.
But one url looking for one tagged item I would just make a PHP plugin I think. Maybe some acf.
WordPress is PHP, not Python.
You’re dealing with two separate processes. Worse yet, long-running processes. When people say “PHP is born to `die()`” they’re not joking. You need a way to manage state for your running queries server-side in WordPress, which probably means your Python script needs to post its results to WP when it finishes, while your frontend polls the server async to see when it’s done.
How the two P’s communicate server-side depends on how much risk/complexity the project demands. You can pipe between the two on the same host if you’re into that, you can use containers, you can use separate servers entirely. Each has very different consequences.