程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Open it up -- python+selenium realizes automatic uploading and publishing of short videos

編輯:Python

Preface

Recently, some people are very interested in automatic uploading and Publishing , I've been talking to me several times in private . today , He must be arranged , You must be a fan of strength .

“ This article introduces the current mainstream short video platforms in turn ( Tiktok 、 Well quickly 、B standing 、 The little red book 、 Micro vision 、 Baidu good video 、 Watermelon Video 、 Wechat video Number 、 Sohu TV

frequency 、 One o'clock 、 Gale 、 Fun headlines ) Short videos are automatically published , Hope to help you more convenient 、 Efficient creation and management of we media .

Python+selenium automation - Short videos of interesting headlines are automatically uploaded and released

Chapter one : Effect display

① Effect display

② Material display (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)

One is video , The other is that the pixel size is not less than the cover of the video .

Chapter two : Implementation process (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)

① Call the enabled browser

By calling the enabled browser , You can directly skip each login process .

Python Exchange of learning Q Group :660193417###
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option
("debuggerAddress", "127.0.0.1:5003")
driver = webdriver.Chrome(options = options)

② Upload videos and covers (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)

# Upload video
driver.find_element_by_xpath('//input
[@type="file"]').send_keys(path_mp4)
# Wait for the video upload to complete
while True:
time.sleep(3)
try:
driver.find_element_by_xpath('//*[contains(text()," Upload successful ")]')
break;
except Exception as e:
print(" The video is still uploading ···")
print(" Video upload completed !")
# Add cover
time.sleep(1)
driver.find_element_by_xpath('//*
[@class="el-upload"]').click()
time.sleep(1)
driver.find_element_by_xpath('//*[text()
=" Custom cover "]').click()
time.sleep(1)
driver.find_element_by_xpath('//*[text()
=" Select Picture "]/../..//input
[@type="file"]').send_keys(path_cover)
time.sleep(3)
driver.find_element_by_xpath('//*[text()
=" indeed set "]').click()

③ Complete source code display (https://jq.qq.com/?_wv=1027&k=Ap5XvyNN)

import selenium
from selenium import webdriver
import pathlib
import time
from selenium.webdriver.common.keys
import Keys
# essential information
# Video storage path
catalog_mp4 = r"C:\Users\Administrator\Desktop\ Video release "
# Video description describe = " Naked eye 3D Look at spider man # Funny # The movie # Visual shock "
time.sleep(10)
options = webdriver.ChromeOptions()
options.add_experimental_option
("debuggerAddress", "127.0.0.1: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 the video path :" + path_mp4)
else:
print(" No video path detected , Termination of procedure !")
exit()
# Get the cover address
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(" Check the path to the cover page :" + path_cover)else:
print(" Cover path not checked , Termination of procedure !")
exit()
def publish_qutoutiao():
'''
effect : Post interesting headline video
'''
# Go to the creator page , And upload the video
driver.get
("https://mp.qutoutiao.net/publish-content/video")
time.sleep(2)
driver.find_element_by_xpath('//input[@type="file"]').send_keys(path_mp4)
# Wait for the video upload to complete
while True:
time.sleep(3)
try:
driver.find_element_by_xpath('//*[contains(text()," Upload successful ")]')
break;
except Exception as e:
print(" The video is still uploading ···")
print(" Video upload completed !")
# Enter title
driver.find_element_by_xpath('//*
[@placeholder=" Content title 5-30 word "]').
clear()
time.sleep(2)
driver.find_element_by_xpath('//*
[@placeholder=" Content title 5-30 word "]').send_keys
(describe)
# Enter a description
time.sleep(1)
driver.find_element_by_xpath
('//textarea').clear()
time.sleep(2)
driver.find_element_by_xpath
('//textarea').send_keys(describe)
# Select classification
time.sleep(1)
driver.find_element_by_xpath('//*[@placeholder=" Please select the category "]').click()
time.sleep(1)
driver.find_element_by_xpath('//*[text()=" The movie "]').click()
time.sleep(1)
driver.find_element_by_xpath('//*[text()=" classification :"]').click()
time.sleep(1)
# Enter the label
time.sleep(1)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').click()
time.sleep(2)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').send_keys(" Visual shock ")
time.sleep(2)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').send_keys(Keys.ENTER)
time.sleep(2)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').send_keys(" Funny ")
time.sleep(2)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').send_keys(Keys.ENTER)
time.sleep(2)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').send_keys(" The movie ")
time.sleep(2)
driver.find_element_by_xpath('//*
[@class="content-tag"]//input').send_keys(Keys.ENTER)
# Add cover
time.sleep(1)
driver.find_element_by_xpath('//*
[@class="el-upload"]').click()
time.sleep(1)
driver.find_element_by_xpath('//*[text()=" Custom cover "]').click()
time.sleep(1)
driver.find_element_by_xpath('//*[text()=" Select Picture "]/../..//input[@type="file"]').send_keys(path_cover)
time.sleep(3)
driver.find_element_by_xpath('//*[text()=" indeed set "]').click()
# Manual inspection and release
#time.sleep(3)
# Click publish
#driver.find_element_by_xpath('//*[text()=" Release "]').click()
# Start video Publishing publish_qutoutiao()

Last

The tutorial on how to upload and publish automatically is put on it , Favorite friends can like the collection , If you have questions, please remember to comment and leave a message , Solve problems in time .

This article ends here , I'm a panda , See you in the next chapter (*◡‿◡).


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved