admin管理员组

文章数量:1660805

目的

大家好,我是watchpoints ,一个只为自己打工程序员,

watchpoints是我github用户名 ,也是我的wechat 用户名,

每天看新闻浪费大量时间,写一个程序 自动提醒你21点远离手机

python实现

步骤1:自动登录

# 从文件中加载 cookies
with open(self.cookies_path, 'r',encoding='utf-8') as myfile:
    cookies = json.load(myfile)
# 将 cookies 加载到页面中
context.add_cookies(cookies)
time.sleep(3)

步骤2 :自动发文

上传图片

HTML代码

<button class="byte-btn byte-btn-primary byte-btn-size-huge byte-btn-shape-square upload-btn" type="button">
  <span>本地上传</span>
  <div class="btn-upload-handle upload-handler">
    <input type="file" accept="image/*" multiple="" title="">
  </div>
</button>


print("图片")
page.locator("css=.syl-toolbar-tool.weitoutiao-image-plugin.static").click()
time.sleep(3)

# 上传图片
with page.expect_file_chooser() as fc_info: 
    page.locator("css=.byte-btn.byte-btn-primary.byte-btn-size-huge.byte-btn-shape-square.upload-btn").locator("nth=0").click()
file_chooser = fc_info.value
file_chooser.set_files(picture_path)

分销

本文由 mdnice 多平台发布

本文标签: 头条发帖今日playwrite