Recently, the gold nuggets check-in function finally came out, forget how to sign in, write a script to sign in

To be perfected, timer

Down the drain, Microsoft’s crawler runs Python, but the NodeJS version can also be used

Copy cookie information for nuggets

You can use the Google plugin editThisCookie

Remember to change the cookie sameSite to None

The full cookie information is not used here…

Write this information to a file, such as 2.json

{ "cookies": [ { "domain": ".juejin.cn", "expirationDate": 1689212789, "hostOnly": false, "httpOnly": false, "name": "_ga", "path": "/", "sameSite": "None", "secure": false, "session": false, "storeId": "0", "value": "GA1.2.257949950.1626079002", "id" : 1}}]Copy the code

Python scripts

import asyncio from playwright.async_api import async_playwright async def run(playwright): browser = await playwright.chromium.launch(headless=False, timeout=60000) context = await browser.new_context(storage_state="2.json") # Open new page page = await Context.new_page () # Go to https://juejin.cn/ await page.goto("https://juejin.cn/") # Click img[Alt ="echone profile "] await page.goto("https://juejin.cn/user/center/signin?from=avatar_menu") # Click text=11 await page.click("button.signin") # --------------------- await context.close() await browser.close() async def main(): async with async_playwright() as playwright: await run(playwright) asyncio.run(main())Copy the code

In need of perfection

  1. Abnormal information was not processed, and some partners did not check in this function
  2. Notification of successful sign-in
  3. A scheduled task, executed daily and not yet written

If you need anything, just let me know.