# -*- coding: utf-8 -*- import json import subprocess def main(): for idx in range(1, 8): name = f"douyinweb-neko-{idx}" py = ( "import json,urllib.request\n" "tabs=json.loads(urllib.request.urlopen('http://127.0.0.1:9222/json/list',timeout=4).read().decode())\n" "for t in tabs:\n" " if t.get('type')=='page':\n" " print((t.get('url') or '')[:140])\n" ) p = subprocess.run( ["docker", "exec", name, "python3", "-c", py], capture_output=True, text=True, timeout=20, ) print("===", name, "===") print((p.stdout or p.stderr or "").strip() or "(no tabs)") if __name__ == "__main__": main()