👾👾[Bug]: Can not login twitter by the cookies
Louis24 opened this issue · comments
Version
1.41.2
Steps to reproduce
Example steps (replace with your own):
- Clone my repo at https://github.com//example
- pip install -r requirements.txt
- python test.py
- You should see the error come up
The Code is following:
from playwright.sync_api import Playwright, sync_playwright
username = "xxx"
password = "xxx"
def login(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False, proxy={"server": "http://127.0.0.1:7890"})
context = browser.new_context()
page = context.new_page()
page.goto("https://twitter.com/i/flow/login?redirect_after_login=%2Fhome")
page.get_by_label("手机号码、邮件地址或用户名").fill(username)
page.get_by_role("button", name="下一步").click()
page.get_by_label("密码", exact=True).fill(password)
page.get_by_test_id("LoginForm_Login_Button").click()
context.storage_state(path="twitter.json")
# ---------------------
context.close()
browser.close()
def post(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False, proxy={"server": "http://127.0.0.1:7890"})
context = browser.new_context(storage_state="twitter.json")
page = context.new_page()
page.goto("https://twitter.com/home")
page.get_by_test_id("app-bar-close").click()
page.get_by_test_id("tweetTextarea_0").fill("haha")
page.get_by_test_id("tweetButtonInline").click()
# ---------------------
context.close()
browser.close()
if __name__ == '__main__':
# with sync_playwright() as playwright:
# login(playwright)
with sync_playwright() as playwright:
post(playwright)
Expected behavior
Expect login, but stuck in this page, seems that the cookie is not working
Actual behavior
Can not login twitter by the cookies
Additional context
No response
Environment
- Operating System: Win10
- CPU: Intel(R)Core(TM) i7-10870H CPU @ 2.20GHz(16 CPUs),~2.2GHz
- Browser: Chromium
- Python Version: [3.11]
- Other info: None
solved, the cookie saved from the codegen is correct, but from storage_state is not
solved, the cookie saved from the codegen is correct, but from storage_state is not
how to solved , could u help
Reference
solved :)