-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexport-woocommerce-products-wordpress.py
51 lines (42 loc) · 1.71 KB
/
export-woocommerce-products-wordpress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Author: Ronknight
# Date: 12/27/18
# Licence: MIT
# Tags: Selenium, Chrome, Wordpress, Woocommerce, Export, Products
# Requires at least: Wordpress 3.0.1
# Tested up to: Wordpress 5.0.2
# Requires: Python 3.7.1, Selenium 1.22, Chromedriver 2.24.1
from selenium import webdriver
import selenium
# Using Chrome to access web
driver = webdriver.Chrome()
# Your Wordpress website admin URL
driver.get('https://yourwordpresssite.com/wp-admin')
# Find login using username and password link (uncomment next line if jetpack login is enabled)
# login_username_password_link = driver.find_element_by_xpath("//a [@class='jetpack-sso-toggle wpcom']")
# Click login using username and password link (uncomment next line if jetpack login is enabled)
# login_username_password_link = driver.find_element_by_xpath("//a [@class='jetpack-sso-toggle wpcom']").click()
# Select the id box
id_box = driver.find_element_by_id('user_login')
# Make python type your username
id_box.send_keys('your-user-name')
# Find password box
pass_box = driver.find_element_by_id('user_pass')
# Make python type your password
pass_box.send_keys('your-password')
# Find login button
login_button = driver.find_element_by_id('wp-submit')
# Click login
login_button.click()
# Find product
product_button = driver.find_element_by_id('menu-posts-product')
# Click product
product_button.click()
# Find export
export_button = driver.find_element_by_partial_link_text('Export')
# Click export
export_button.click()
# Find generate button
generate_button = driver.find_element_by_xpath("//button [@type='submit' and @value='Generate CSV']")
# Click generate button
generate_button.click()
# These should initiate the download. The downloaded file should be on your downloads folder.