Home » Wordpress » Automate WordPress Install from python

Automate WordPress Install from python

Posted by: admin November 30, 2017 Leave a comment

Questions:

I have a python program that sets up a wordpress site on my server. It downloads the zip and unzips it into a directory, sets up the database and user, configures the config file. Now I would like to call the the wp_install function in wp-admin/include/upgrade.php and pass it the parameters it needs $weblog_title, $user_name, $admin_email …

My question is how can I call this function from python? Can I do a urllib.urlopen and if so how do I call the wp_install function with the right parameters?

Answers:

It looks like wp_install() gets called inside of /wp-admin/install.php during step 1, and after form data has been validated. If you submit ?step=1& … (all of the other required form fields) it should result in calling wp_install. So yes, you should be able to use urllib(2) for this.

Questions:
Answers:

Urllib is an option, but because your script is running on the local machine anyway, I would probably use os.system. That way you can execute the php script like from a shell. You have to look into the php file on how to pass the parameters.