百度贴吧有一键签到,但是我懒,不想登录啥的。
然后用了下 playwright 自动生成代码,发现还挺好用的,生成这些操作简单的小程序很方便。
代码:
from playwright import sync_playwright
import time
def run(playwright):
browser = playwright.chromium.launch(headless=False)
context = browser.newContext()
page = context.newPage()
page.goto("http://tieba.baidu.com/f/user/passport?jumpUrl=http://tieba.baidu.com")
page.click("text=\"用户名登录\"")
page.click("input[name=\"userName\"]")
page.fill("input[name=\"userName\"]", "你的账号")
page.fill("input[name=\"password\"]", "你的密码")
page.click("input[value=\"登录\"]")
page.click("//div[normalize-space(.)='爱逛的吧']/div[3]/div/a")
page.click("text=\"签到-非会员\"")
page.close()
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)