|
|
|
|
|
|
|
|
|
from scrap_util import getDriver |
|
import helium as hm |
|
import pickle |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = 'https://creator.douyin.com/' |
|
movie_path = "./movie_output/" |
|
own_movie_csv = "公告信息_test.csv" |
|
|
|
cookie_f = './cookie_list/{}.pkl' |
|
|
|
|
|
|
|
|
|
|
|
def get_cookie(fn): |
|
|
|
|
|
|
|
cookies = pickle.load(open(fn, "rb")) |
|
new_cookie = {} |
|
for cookie in cookies: |
|
if 'expiry' in cookie: |
|
continue |
|
|
|
|
|
new_cookie[cookie] = cookies[cookie] |
|
|
|
return new_cookie |
|
|
|
|
|
|
|
def senDouyin(driver = None, account_name="zdx_1", title='北京市三支一扶公告', movie_path = "./movie_output/a.mp4", loc = "北京"): |
|
import time |
|
cookie_local_f = cookie_f.format(account_name) |
|
local_cookie = get_cookie(cookie_local_f) |
|
|
|
|
|
hm.set_driver(driver) |
|
hm.go_to("www.baidu.com") |
|
hm.go_to(url) |
|
|
|
|
|
|
|
for k,v in local_cookie.items(): |
|
driver.add_cookie({'name':k, 'value':v}) |
|
|
|
hm.go_to(url) |
|
|
|
if hm.Button("开始体验").exists(): |
|
|
|
hm.click(hm.Button("开始体验")) |
|
if hm.Button("下一步").exists(): |
|
hm.click(hm.Button("下一步")) |
|
hm.click(hm.Button("完成")) |
|
time.sleep(1) |
|
hm.click(hm.Button("发布作品")) |
|
time.sleep(1) |
|
hm.drag_file(movie_path, to="或直接将视频文件拖入此区域") |
|
|
|
time.sleep(2) |
|
if hm.Text("我知道了").exists(): |
|
hm.click(hm.Text("我知道了")) |
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
driver.get_screenshot_as_file("e1_wirte_title.png") |
|
time.sleep(3) |
|
|
|
driver.find_element_by_class_name("editor-kit-editor-container").click() |
|
|
|
hm.write(title) |
|
time.sleep(1) |
|
driver.get_screenshot_as_file("e1_start_choose封面.png") |
|
if hm.Text("选择封面").exists(): |
|
hm.click(hm.Text("选择封面")) |
|
if hm.Text("设置封面").exists(): |
|
hm.click("设置封面") |
|
time.sleep(1) |
|
if hm.Button("完成").exists(): |
|
hm.click(hm.Button("完成")) |
|
|
|
|
|
driver.get_screenshot_as_file("e1_完成_choose封面.png") |
|
time.sleep(1) |
|
|
|
hm.click("输入地理位置") |
|
time.sleep(1) |
|
|
|
hm.write("北京市") |
|
time.sleep(1) |
|
hm.click("北京市") |
|
|
|
driver.find_element_by_class_name("button--1SZwR").click() |
|
time.sleep(1) |
|
driver.get_screenshot_as_file("e1_after_发布.png") |
|
driver.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|