learn-spider/spider/mail_qq.py

25 lines
762 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from playwright.sync_api import sync_playwright
from bs4 import BeautifulSoup
def crawl_vue_app():
with sync_playwright() as p:
# 启动浏览器headless=False 可以看到浏览器窗口)
browser = p.chromium.launch(headless=False)
page = browser.new_page()
# 访问页面
page.goto('https://mail.qq.com')
context = browser.new_context()
page = context.new_page()
# 访问页面
page.goto('https://caigou.chinatelecom.com.cn/')
input("请在浏览器中完成登录,然后按 Enter 继续...")
context.storage_state(path='auth.json')
print("登录状态已保存到 auth.json")
browser.close()
if __name__ == "__main__":
crawl_vue_app()