In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to use Python+selenium to achieve automated Kuaishou short video release". In daily operation, I believe many people have doubts about how to use Python+selenium to achieve automated Kuaishou short video distribution. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to use Python+selenium to achieve automatic Kuaishou short video release"! Next, please follow the editor to study!
Chapter 1: effect display ① effect display
The ② material shows one as a video and the other as a cover with a pixel size of no less than the video.
Chapter 2: implementing procedure ① calls enabled browsers by calling enabled browsers, you can skip each login process directly.
From selenium import webdriveroptions = webdriver.ChromeOptions () options.add_experimental_option ("debuggerAddress", "127.0.0.1 ② 5003") driver = webdriver.Chrome (options = options) how to use the video and image upload feature can be found in:
# upload local video driver.find_element_by_xpath ('/ / input [@ type= "file"]') .send_keys (path_mp4) # add cover time.sleep (2) driver.find_element_by_xpath ('/ / button//* [contains (text ()) "Edit cover")]'). Click () # enter the iframe framework driver.switch_to.frame (driver.find_element_by_xpath ('/ / iframe')) time.sleep (1) driver.find_element_by_xpath ('/ / input [@ type= "file"]'). Send_keys (path_cover) time.sleep (10) driver.find_element_by_xpath ('/ / button [text () = "OK"]'). Click () # exit the default framework driver.switch_to_default_content () ③ full source code to display import seleniumfrom selenium import webdriverimport pathlibimport timefrom selenium.webdriver.common.keys import Keys# basic information # Video storage path catalog_mp4 = r "C:\ Users\ Administrator\ Desktop\ Video release" # Video description describe = "watching Spider-Man in 3D # funny # Movie # Visual shock" time.sleep (10) options = webdriver.ChromeOptions ( ) options.add_experimental_option ("debuggerAddress" "127.0.0.1 options 5003") driver = webdriver.Chrome (options = options) path = pathlib.Path (catalog_mp4) # Video address acquisition path_mp4 = "" for i in path.iterdir (): if (".mp4" in str (I)): path_mp4 = str (I) Break;if (path_mp4! = ""): print ("check video path:" + path_mp4) else: print ("No video path checked, program terminated!") Exit () # cover address acquisition path_cover = "" for i in path.iterdir (): if (".png" in str (I) or ".jpg" in str (I)): path_cover = str (I); break;if (path_cover! = "): print (" cover path checked: "+ path_cover) else: print (" cover path not checked, program terminated! ") Exit () def publish_kuaishou ():''function: publish Kuaishou video to enter the creator page And upload the video driver.get ("https://cp.kuaishou.com/article/publish/video?origin=www.kuaishou.com") time.sleep (3) driver.find_element_by_xpath ('/ / input [@ type=" file "]'). Send_keys (path_mp4) # wait for the video upload to be completed while True: time.sleep (3) try: driver. Find_element_by_xpath ('/ / * [contains (text ()) "uploaded successfully")]') break Except Exception as e: print ("video is still uploading") print ("video has been uploaded!") # add cover time.sleep (2) driver.find_element_by_xpath ('/ / button//* [contains (text ()) "Edit cover")]'). Click () # enter the iframe framework driver.switch_to.frame (driver.find_element_by_xpath ('/ iframe')) time.sleep (1) driver.find_element_by_xpath ('/ / input [@ type= "file"]'). Send_keys (path_cover) time.sleep (10) driver.find_element_by_xpath ('/ / button [text ()) = "OK"]'). Click () # exit the default frame driver.switch_to_default_content () # switch regular video time.sleep (2) driver.find_element_by_xpath ('/ * [contains (text ()) "upload regular videos")]'). Click () time.sleep (3) # enter video description driver.find_element_by_xpath ('/ * [@ placeholder= "to add appropriate topics and descriptions Works can get more recommendations ~ "]'). Send_keys (describe) # Select category driver.find_element_by_xpath ('/ * [@ placeholder=" Please select "]'). Click () time.sleep (2) driver.find_element_by_xpath ('/ / * [text () =" Film "]'). Click () time.sleep (1) # manually Check and publish # time.sleep (3) # # Click publish # driver.find_element_by_xpath ('/ / * [text () = "publish"]') .click () # start video publishing publish_kuaishou () here The study on "how to use Python+selenium to automate Kuaishou short video release" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.