playwrite今日头条自动发帖

目的

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

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

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

python实现

步骤1:自动登录

alt
# 从文件中加载 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 :自动发文

alt
alt
alt
alt

上传图片

alt

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)
alt

分销

alt
alt

本文由 mdnice 多平台发布

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值