Publish Posts With Notifications in Selenium – Python Automation In Hindi

Python Selenium

WordPress Publish Posts With Notifications in SeleniumPython Automation In Hindi – Mujhe Aapni Website Me Post Ki Notification Ko Send Karne Ke Liye Post Ko Bar Bar Open Karna Padta Tha, Isliye Maine Ek Bar Python Automate Code Likhe Ke Aapne Kaam Ko Aashan Bana Liya |

Ye Python Selenium WordPress Script Aapne Aap Login Karke Or Posts Me Jake Random Post Open karne Notifications Par Click Karke Update Kar Degi, Jisse User ko Aasani Se Notifications Send Ho jayegi |

Publish Posts With Notifications in Selenium

Maine Isme Python Selenium library Ka Istemal Kiya Hai, Agar Aapko Python Selenium Library In Hindi Me Learn Karni Hai, To Aap Niche Diye Link Kar Click Karke Python Selenium Tutorial Ko Easily Learn Kar Sate Hai |

Also Read – Python Selenium Library

Me Aapko Step By Step Batata Hu And Fir Bad Me Ek Jagah Likhe Ke Bad Code Ko Run Karta Hai|

Step 1:

Aapko Yaha Par Pahle time And selenium and random Module Ko Import Karna Hai, And Fir Aapko WordPress User Id And Password Aapko Yaha Par Put Karna Hai |

import time
from selenium import webdriver
import random

user = 'input_wordpress_user_id'
pasw = 'input_wordpress_pass'

Step 2:

Fir Aapko while True: Condition Laga ke Aapko Uske Under Baki Code Likhna Hai, While True Isliye Lagate Hai, Kyoki Ye Condition Hamesha Chalti Rahe |

while True:

Step 3:

Yaha Par Pahle x Variable Me Current Time Leke Print Kara Diya Hai, Fir Uske Bad Chrome Ka Object (browser) Create karke WordPress Login Url Put Karna Hai Or Fir get() Function Ki Help Se Url Ko Get Karke URL Open Ho Jayega And Uske Bad Fir Current URL Title Print Ho jayega |

	x = time.ctime()
    print(f"Current Time : {x}")

    browser = webdriver.Chrome(executable_path="E:\\chromedriver_win32\\chromedriver.exe")
    #initializing driver
    url ="wordpress_login_url"
    browser.get(url)

    print(browser.title)

Dhiyan Rahe Ki Aapko Line No 4 me Aapko Chrome Driver Ka Path Dena Hoga, Agar Aapke Pass Download Nhi Hai To Aap Niche Link Par Click Karke Download Kar Sakte Hai |

Click Here – Download Chorme Driver

Step 4:

Yaha Par browser.maximize_window() Ki help Window Maximize Ho Jayegi And Uske Bad Fir Ye Line (3,4) [ok variable] Tab Aapko Istemal Karni Hai, Jab Aapko Niche Diye Gaye Me Dikhaya Gaya Hai, Agar Aapko WordPress Login Karke Time, Is Tarah Ka Aata Hai To Line 3 And 4 Tabhi Istemal Kare, Nhi To Aap Is Line Ko Remove Karde |

	browser.maximize_window()

    ok = browser.find_element_by_xpath("//*[@id='jetpack-sso-wrap']/a[1]")
    ok.click()

Step 5:

Niche Diya Gaya Code User_name And Pass_word Fill Karke And Uske Bad ye Log in Button Par Click Karke Login ho Jayega, Jaise Niche Diye Gaye Image Me Dikhaya Gaya Hai |

	# #filling login section
    username = browser.find_element_by_name("log")
    username.send_keys(user)

    password = browser.find_element_by_name("pwd")
    password.send_keys(pasw)

    login = browser.find_element_by_name("wp-submit").click()
    

Step 6:

Ye Line WordPress Deshboard Me Posts Link Par Click karke All Post Aa Jayegen |

	posts = browser.find_element_by_xpath("//*[@id='menu-posts']/a").click()

Step 7:

Ye Code All Post Me Random 1 se 10 Tak Koi Bhi Page Choice Karega And Fir Random Page Ki Pahli Post Par Click Karke Edit Mode Me Chala Jayega |

	for i in range(random.randint(1,10)):
        next_page = browser.find_element_by_class_name("next-page").click()


    title = browser.find_element_by_class_name("row-title").click()
    print(browser.title)

Step 7:

Jab Ham New Koi Post Kisi Browser Me Pahli Bar Open karte Hai, To Box Har Bar Aata Hai, Isliye Ise Remove Karne ke Liye Niche Diya Code Kaam karta Hai |

	for i in range(3):
        box = browser.find_element_by_class_name("components-guide__forward-button")
        box.click()

    finish_box = browser.find_element_by_class_name("components-guide__finish-button")
    finish_box.click()

Step 8:

Ye Code Notification Par Click Karke And Fir Update Button Par Click karke Publish Post Me Chala Jayega Or Ye Tab Tak Kam Se Kam 10 Second Tak Wait Karega, Kyoki Update Hone Time Lagta Hai, And Fir browser.quit() Browser Quit Ho Jayega |

	select = browser.find_element_by_name("send_onesignal_notification").click()
    publish = browser.find_element_by_class_name("editor-post-publish-button__button").click()
    time.sleep(10)
    print('Publish Post')
    browser.quit()

Step 9:

Ye Code Fir 4 Hour Yai 14400 Second Wait Karega And Fir Uske Bad Same Task Again Repeat Hogi|

	print("Please Wait 4 Hours For Again Publishing Post")
    time.sleep(14400)

Step Final:

Yaha Par Ab Sara Code Ek Editor me Rakha Gaya Hai, Aap Ise Ab Istemal kar Sakte Hai, Bas Aapko WordPress Url And WordPress User Name And WordPress Password Aapko Dena Hoga, Baki Kaam Ye Code Aapne Aap Kar Dega |

import time
from selenium import webdriver
import random

user = 'input_wordpress_user_id'
pasw = 'input_wordpress_pass'


while True:
    x = time.ctime()
    print(f"Current Time : {x}")

    browser = webdriver.Chrome(executable_path="E:\\chromedriver_win32\\chromedriver.exe")
    #initializing driver
    uurl ="wordpress_login_url"
    browser.get(url)

    print(browser.title)
    browser.maximize_window()

    ok = browser.find_element_by_xpath("//*[@id='jetpack-sso-wrap']/a[1]")
    ok.click()

    # #filling login section
    username = browser.find_element_by_name("log")
    username.send_keys(user)

    password = browser.find_element_by_name("pwd")
    password.send_keys(pasw)

    login = browser.find_element_by_name("wp-submit").click()

    posts = browser.find_element_by_xpath("//*[@id='menu-posts']/a").click()

    for i in range(random.randint(1,10)):
        next_page = browser.find_element_by_class_name("next-page").click()


    title = browser.find_element_by_class_name("row-title").click()
    print(browser.title)

    for i in range(3):
        box = browser.find_element_by_class_name("components-guide__forward-button")
        box.click()

    finish_box = browser.find_element_by_class_name("components-guide__finish-button")
    finish_box.click()

    select = browser.find_element_by_name("send_onesignal_notification").click()
    publish = browser.find_element_by_class_name("editor-post-publish-button__button").click()
    time.sleep(10)
    print('Publish Post')
    browser.quit()

    print("Please Wait 4 Hours For Again Publishing Post")
    time.sleep(14400)

Output:

4 thoughts on “Publish Posts With Notifications in Selenium – Python Automation In Hindi

  1. Sir I don’ t have any accounts in WordPress means no post…do u have any demo user and password

Leave a Reply

Your email address will not be published. Required fields are marked *