Skip to content

How to Get the Latest version of WordPress using Python

Download the latest version of WordPress using Python

  • upload the wp-new file to the directory where you want to install WordPress
  • run the “python wp-new” command within the directory where you have the wp-new file.

Code: https://github.com/devuri/python-wp-new


#!/usr/bin/env python

import requests
import subprocess

#vars
WP_URL = 'https://wordpress.org/latest.zip'

req_error = 'sorry we cant find the file'
downloading = 'Everything Looks good Lets Download WordPress'

# make sure we can reach the url
wpreq = requests.get(WP_URL)
if wpreq.status_code != 200:
    print(str(req_error))
elif wpreq.status_code == 200:
    print(downloading)
    subprocess.call(['wget', WP_URL])
    subprocess.call(['unzip', 'latest.zip'])
    subprocess.call(['rm','latest.zip'])
    subprocess.call('mv wordpress/*.* .', shell=True)
    subprocess.call('mv wordpress/* .', shell=True)
    subprocess.call(['ls', '-l'])
    subprocess.call(['rm', '-r', 'wordpress'])
    print("Awesome WordPress is ready")
    #subprocess.call(['rm','wp-new'])